Skip to content
PHP Ecosystem
Explore

Testing

This content is not available in your language yet.

This package provides a consistent set of Composer scripts for local validation.

Tool references:

Run Rector to apply automated code refactoring. This command modifies files.

Terminal window
composer rector

Preview the refactoring without modifying files.

Terminal window
composer rector-check

Check coding standards without modifying files.

Terminal window
composer ecs-check

Apply coding standard fixes. Review the changes before keeping them.

Terminal window
composer ecs

Verify that runtime dependencies are correctly declared in composer.json.

Terminal window
composer check-dependencies

Run mutation testing.

Terminal window
composer mutation

Run mutation testing with PHPStan static analysis enabled.

Terminal window
composer mutation-static

Thresholds, thread count and memory options live in infection.json5. CI enforces the same thresholds.

Make the CLI tools used by the shared quality workflow available on PATH: actionlint with its ShellCheck helper, codespell, EditorConfig Checker, markdownlint-cli2, Prettier and yamllint. Run all checks:

Terminal window
composer quality

Each tool also has its own script:

Terminal window
composer actionlint
composer codespell
composer editorconfig-checker
composer markdownlint
composer prettier
composer yamllint

The linter configuration lives in .github/linters, and the Prettier configuration in .prettierrc.json and .prettierignore. CI uses the same files.

Run static analysis.

Terminal window
composer static

Run the full test suite.

Terminal window
composer tests

Make zizmor and Gitleaks available on PATH. Audit the current workflow files with the same pedantic persona used by the shared security workflow:

Terminal window
composer zizmor

Scan Git history for secrets with the repository’s Gitleaks configuration:

Terminal window
composer gitleaks

Run both checks. Findings make the command fail; inspect them rather than disabling the checks.

Terminal window
composer security

Zizmor needs GitHub API access for its online audits. If the tool runs offline, report that limit separately. To request an offline audit explicitly:

Terminal window
composer zizmor -- --offline

Report hosted CI execution and its PHP/OS matrix separately from these local commands. Keep generated reports in ignored internal/.

Composer scripts support forwarding additional arguments using --.

Run PHPUnit with code coverage report generation.

Terminal window
composer tests -- --coverage-html internal/coverage

Run PHPStan with a different memory limit.

Terminal window
composer static -- --memory-limit=512M

Run the package suite with each supported Yii line in an isolated checkout, keeping PHP 8.3 or higher:

Terminal window
composer require yiisoft/yii2:2.0.55 --with-all-dependencies
composer tests
composer require yiisoft/yii2:22.0.x-dev --with-all-dependencies
composer tests

These commands change the checkout’s Composer requirements and lock file; use disposable checkouts for a matrix. The suite uses real bridge request/response processing with mocked RoadRunner transport. It covers emission and processing failures, after-send ordering, finalization when error reporting fails, declined dispatches during recycling, preservation of finalization and shutdown exceptions, session cookie selection, and upload reset. It does not start the RoadRunner server.

For an application smoke test, run its configured RoadRunner binary and send consecutive requests through the same worker: two visitors, absent/invalid session cookies, an upload followed by no upload, and streamed downloads. Verify response bytes and status, after-send ordering, and worker replacement after a fatal callback. Confirm each request enters application handling once and the first request after replacement succeeds. Record the binary version and dependency revisions. If the binary or application fixture is unavailable, report that runtime check as pending rather than treating mocked transport tests as server validation.

Back to documentation