Skip to content

test: isolate security helper services and enable random helper tests - #10730

Open
MohamedRF wants to merge 1 commit into
codeigniter4:developfrom
MohamedRF:test/helpers-random-order
Open

MohamedRF wants to merge 1 commit into
codeigniter4:developfrom
MohamedRF:test/helpers-random-order

Conversation

@MohamedRF

Copy link
Copy Markdown

Description
Reset shared services in SecurityHelperTest::setUp() so it does not reuse a request or security mock left by another helper test. With random seed 1793892530, SiteUrlCliTest runs first and leaves a CLIRequest in the shared request service. Constructing MockSecurity later fails because Security::$request requires an IncomingRequest.

Enable Helpers in the random-test configuration after verifying the component with the failing seed and repeated randomized runs. This completes the Helpers component of #9968; the overall issue remains open for other components.

Validation

  • Before the fix: vendor/bin/phpunit tests/system/Helpers --order-by=random --random-order-seed=1793892530 --no-coverage fails with a CLIRequest/IncomingRequest TypeError.
  • After the fix: the same command passes (577 tests, 984 assertions).
  • Ten random component runs through .github/scripts/run-random-tests.sh --component Helpers --repeat 10 --max-jobs 2 --quiet pass.
  • Deterministic seeds 1–10 pass.
  • File-scoped PHP CS Fixer, Rector dry run, and PHPStan checks pass.
  • git diff --check passes.

Tested with PHP 8.5.12 / PHPUnit 11.5.57 on macOS. The full platform matrix is left to CI.

Checklist:

  • Securely signed commit
  • Existing regression tests verified with the previously failing random seed
  • Conforms to style guide
  • PHPDoc and user guide changes: not applicable; this changes test isolation and CI coverage only.

This branch has not been deployed

No deployments
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.

3 participants