Skip to content

Raise test coverage to 100% and harden humanize()#5

Merged
khaledalam merged 1 commit into
mainfrom
test/coverage
Jul 10, 2026
Merged

Raise test coverage to 100% and harden humanize()#5
khaledalam merged 1 commit into
mainfrom
test/coverage

Conversation

@khaledalam

Copy link
Copy Markdown
Owner

Codecov was ~45% because coverage collection can't attribute autoload-time code (Name::label() and the bootstrap file ran during autoload, before the coverage window). This restructures so all logic is measured.

Changes

  • Default registration extracted to a testable DefaultUnits::register(); bootstrap.php is now a one-line shim (excluded from coverage as an unmeasurable autoload entrypoint).
  • New PHPUnit test suite (*Test.php) alongside the existing .phpt tests — covers the enum labels, registry, dimensions, unit stringification, Quantity edge branches, and the Laravel provider + cast. This also addresses the earlier "contributors expect PHPUnit, not .phpt" concern.
  • humanize() bug fix — it previously called get() on every ladder symbol and threw if the registry was only partially populated; it now skips unregistered ladder units. Found by the new coverage test.

Result

  • 100% coverage — Classes 8/8, Methods 44/44, Lines 296/296 (measured locally with PCOV).
  • 56 tests, 299 assertions, no deprecations. PHPStan level max clean, CS-Fixer clean.

@khaledalam khaledalam merged commit eaa9420 into main Jul 10, 2026
11 checks passed
@khaledalam khaledalam deleted the test/coverage branch July 10, 2026 17:16
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.

1 participant