Skip to content

test: raise the coverage to 97.5 % - #16

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

ogorzalka merged 2 commits into
mainfrom
cov/schedule

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Raises the coverage of the package from 84.7 % to 97.5 % (measured locally with PHP 8.4 and pcov; equal to the recorded ratchet), with tests only (src/ is untouched).

40 tests (107 to 147) in five new files and a fixture: the cron-event and migrate commands, the registrar, the edges of the engine (the cron options interceptor, CronIndex), and the schedule surface (fluent shortcuts, ScheduleFake, ScheduleDiscovery). tests/Support/WpCliFake.php simulates WP-CLI (WP_CLI, Cron_Event_Command, Formatter, WP_Error), each guarded by class_exists. Time is fixed: ScheduleEngine has an injectable clock (useClock) and the tests use fixed timestamps; only ActionSchedulerDriver reads time().

One existing test is touched: PackageBoundaryTest gets six lines. Once the WP-CLI fakes are loaded, the architecture test sees WP_CLI, WP_CLI\Formatter, Cron_Event_Command, is_wp_error and wp_list_pluck used in src/, which it ignored before only because they did not resolve; they are added to its ignoring list with the other WordPress names. Nothing else in that test is relaxed.

Not covered, and why: the ActionScheduler-absent paths of ActionSchedulerDriver (lines 50, 58; the fake class stays defined for the process), Schedule.php 162-164 (driver choice when add_filter does not exist: Brain Monkey defines it for the process), the AssertionError fallback of ScheduleFake without PHPUnit, the Cron_Event_Command-absent branch of Registrar (Pest 3 has no runInSeparateProcess()), and a few isolated lines. Seen in the code and left as it is: ScheduleDiscovery.php:135 builds the class name for a class without namespace as \Name, so a log message starts with a backslash (cosmetic).

The ratchet in .harness.json goes from 84.7 to 97. The 147 tests pass in random orders and in a Linux container (php:8.4-cli); Pint, PHPStan, Rector (--dry-run) and tests/Arch.php are clean.

@ogorzalka
ogorzalka merged commit 638d080 into main Nov 13, 2026
15 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