Skip to content

test: raise the coverage to 98.8 % - #12

Merged
ogorzalka merged 2 commits into
mainfrom
cov/entity
Nov 13, 2026
Merged

ogorzalka merged 2 commits into
mainfrom
cov/entity

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Raises the coverage of the package from 54.2 % to 98.8 %, with tests only (src/ is untouched).

184 test cases in four files (the suite goes from 77 to 261): every fluent accessor of Entity, PostType and Taxonomy keeps its value and stays chainable (datasets), and the fallbacks to register_post_type / register_taxonomy. Entity, PostType and Taxonomy are at 100 %. In tests/Helpers/helpers.php the global register_post_type and register_taxonomy stand-ins now also record their calls in $GLOBALS['entity_test_registrations'] (four lines added, none removed; no other test reads it).

Not covered: PostTypeRegistryAdapter (83.3 %: lines 44, 51, 65) and TaxonomyRegistryAdapter (88.9 %: lines 53, 68), the branches taken when the WordPress or Extended CPTs registration functions do not exist. A global function cannot be removed in a running process, and johnbillion/extended-cpts defines its own through the Composer autoload.

Seen in the code and left as it is:

  • TaxonomyRegistryAdapter::register() does unset($args['object_type']) after calling registerTaxonomy, which has no effect ($args is not used again), and a call without object_type is ignored without an error or a message (a test pins it).
  • Entity::showInMenu() has no return type, unlike its neighbours (: self).
  • The composer phpstan script analyses tests too and reports 57 errors that are already on main (deprecated calls in the existing tests); the CI uses phpstan.neon (src only), which is clean.

The coverage ratchet in .harness.json goes from 54.23 to 98. Measured with pest --coverage (PHP 8.4, pcov, the CI driver); the 261 tests pass in random orders; Pint, PHPStan, Rector (--dry-run) and tests/Arch.php are clean.

@ogorzalka
ogorzalka merged commit 8c7b8c6 into main Nov 13, 2026
9 checks passed
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