Skip to content

Increase unit test coverage for Support utilities (Steam, Amount, ParseDateString)#7

Open
devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
devin/1760981686-improve-test-coverage
Open

Increase unit test coverage for Support utilities (Steam, Amount, ParseDateString)#7
devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
devin/1760981686-improve-test-coverage

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Link to Devin run: https://app.devin.ai/sessions/321f0ee3ac014cbe994f3803fdae8be1
Requested by: Sam Fertig (sam.fertig@cognition.ai), GitHub: @samfert-codeium

Summary

This PR addresses the 0% test coverage reported by SonarQube by adding comprehensive unit tests for three previously untested Support utility classes and establishing CI integration for ongoing coverage tracking.

Changes in this pull request

  • Added 66 new unit tests across 3 test files (total tests: 373 → 439):

    • SteamBcroundTest.php: 19 tests for the Steam::bcround() method covering null/empty inputs, positive/negative decimals, scientific notation, and edge cases
    • AmountGetAmountJsConfigTest.php: 26 tests for the Amount::getAmountJsConfig() static method covering all 5 sign position modes (0-4), spacing variants, and currency symbol positioning
    • ParseDateStringRangeTest.php: 21 tests for ParseDateString::isDateRange() and parseRange() methods covering day/month/year ranges and combinations
  • Modified phpunit.xml to change pathCoverage from true to false:

    • Path coverage requires Xdebug (extremely slow for this codebase - 9+ minutes with no progress)
    • Line coverage works with pcov (completes in ~28 seconds)
    • This trade-off enables practical coverage collection in CI
  • Created GitHub Actions workflow (.github/workflows/sonarcloud.yml):

    • Runs on push to main and all pull requests
    • Installs PHP 8.4 with pcov coverage driver
    • Executes unit tests with coverage collection
    • Uploads results to SonarCloud for analysis
    • Requires SONAR_TOKEN secret to be configured (should already exist from PR Set up SonarQube integration for local analysis #5)

Test Coverage Improvement

  • Before: 0.0% coverage (47,379 lines to cover, per SonarQube)
  • After (local run): 1.82% coverage (1,044 covered elements out of 57,282)
  • All 439 tests pass with 451 assertions

Review Checklist

⚠️ Important items for review:

  1. Test correctness: Verify the test assertions match expected behavior, especially:

    • Amount::getAmountJsConfig() formatting for all sign position modes
    • Steam::bcround() behavior with edge cases (null, empty, scientific notation)
    • ParseDateString range parsing logic
  2. Configuration change: Confirm that disabling path coverage (pathCoverage="false") is acceptable given the performance trade-off

  3. CI setup: Verify SONAR_TOKEN secret is configured in repository settings (workflow will fail without it)

  4. Scope: This PR provides a foundation with 1.82% coverage. Consider whether additional test coverage should be required before merge or can be addressed in follow-up PRs.

Testing

  • ✅ All 439 unit tests pass locally (including 66 new tests)
  • ✅ Coverage report generated successfully in 28 seconds with pcov
  • ⏳ CI workflow not yet tested (requires merge or test run)

Note: This establishes the foundation for ongoing coverage tracking. Many Support utility classes remain untested and will require additional test coverage in future PRs.

- Created comprehensive unit tests for 3 untested Support utility classes:
  - SteamBcroundTest.php: 19 test cases for Steam::bcround() method
  - AmountGetAmountJsConfigTest.php: 26 test cases for Amount::getAmountJsConfig()
  - ParseDateStringRangeTest.php: 21 test cases for ParseDateString range methods

- Modified phpunit.xml to use line coverage instead of path coverage
  - Changed pathCoverage from true to false to enable pcov driver
  - Pcov is significantly faster than xdebug for coverage collection

- Created GitHub Actions workflow (.github/workflows/sonarcloud.yml)
  - Runs unit tests with coverage on push to main and pull requests
  - Uses pcov for fast coverage generation
  - Uploads coverage results to SonarCloud

Test Results:
- All 439 unit tests pass (66 new tests added)
- Coverage increased from 0.0% to 1.82% (1,044 covered elements)
- Coverage report generated successfully in coverage.xml

This establishes the foundation for ongoing coverage tracking and
improvement in the codebase.

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration Bot and others added 2 commits October 20, 2025 18:02
The workflow was failing during composer install because Laravel's
post-install script (firefly-iii:instructions install) requires APP_KEY
and other environment variables to be set.

Added environment setup step before composer install with:
- APP_ENV=testing
- APP_KEY (dummy key for CI)
- DB_CONNECTION=sqlite
- DB_DATABASE (empty for SQLite)
- APP_LOG_LEVEL=notice
- AUDIT_LOG_LEVEL=emergency

This follows standard Laravel CI practices and matches the environment
variables configured in phpunit.xml.

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
The workflow was failing during test execution because Laravel was trying
to access a SQLite database file at storage/database/database.sqlite that
doesn't exist in the CI environment.

Changed DB_DATABASE from empty string to ':memory:' which uses an in-memory
SQLite database for tests. This is the standard approach for Laravel CI
testing and avoids filesystem dependencies.

This is the 2nd fix for the SonarCloud workflow:
- 1st fix: Added APP_KEY and other required Laravel env vars (successful)
- 2nd fix: Changed DB_DATABASE to :memory: for tests (this commit)

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants