Skip to content

test: raise unit coverage to 99 %, two permission fixes - #25

Merged
ogorzalka merged 2 commits into
mainfrom
test/unit-coverage
Nov 27, 2026
Merged

ogorzalka merged 2 commits into
mainfrom
test/unit-coverage

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Raises the line coverage of src/ by the unit suite from 85.3 % (2146/2516) on main to 99.7 % (2585/2592), measured with pcov on PHP 8.4. #24 alone takes it to 93.2 %.

Stacked on #24: retarget to main before the chore/phpstan-max branch is deleted.

The tests assert effects (answers, headers, queries, which user the code runs as and whether it is given back), with attention to the failure paths: preview sessions and their refusals, who may see a file, REST answers that fail, filters and blocks that throw.

Two fixes (first commit)

  • A file in the media trash is given only to a user who may read it, as a private file is.
  • The redirects list the old slugs of content types with public pages only, as WordPress redirects them.

Both stay within the HTTP contract. Each has a test that fails without the fix.

Test support

  • tests/Stubs/wordpress.php declares the few WordPress classes the code builds with new (and a Contact Form 7 stand-in).
  • What a constant or an exit decides runs in a PHP process of its own (tests/Fixtures/isolated.php). These checks are real, but pcov does not count them: they are the 7 lines left.
  • A GraphQL test left an Authorization header behind, which made another test fail in random order.

Notes

  • No coverage exclusion is added. register.php already had @codeCoverageIgnore around the WP-CLI registration, so it is not measured.
  • .harness.json records no coverage floor: recording one is left to a maintainer.

Olivier Gorzalka added 2 commits November 27, 2026 17:09
Preview, manifest, search, doctor, SEO sources, service provider, media
permissions, constants (each in its own process). A GraphQL test no longer
leaves an Authorization header behind for the next test.
@ogorzalka
ogorzalka changed the base branch from chore/phpstan-max to main November 27, 2026 16:19
@ogorzalka
ogorzalka merged commit 4cb9041 into main Nov 27, 2026
12 checks passed
@ogorzalka
ogorzalka deleted the test/unit-coverage branch November 27, 2026 16:20
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