跳转到内容
PHP Ecosystem
Explore

Testing

此内容尚不支持你的语言。

This package provides a consistent set of Composer scripts for local validation. Install the development dependencies from the chosen package revision, then run the scripts from the package root.

Tool references:

Run Rector to apply automated code refactoring. This command modifies files; do not use it as a read-only validation command.

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

Mutation testing is a separate, slower check that needs a supported coverage driver. 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.

CI runs actionlint, codespell, EditorConfig Checker, markdownlint-cli2, Prettier and yamllint through the shared yii2-framework/actions quality workflow. The repository’s formatting rules stay in .editorconfig.

Make actionlint and ShellCheck available on PATH to lint workflows locally.

Terminal window
composer actionlint

Run static analysis. PHPStan analyzes source and tests at the configured maximum level.

Terminal window
composer static

Run the full test suite. PHPUnit fails on risky tests and warnings.

Terminal window
composer tests

CI runs zizmor and Gitleaks through the shared security workflow. Gitleaks uses its default rules and the allowlist in .github/linters/.gitleaks.toml. The Gitleaks scan requires GITLEAKS_LICENSE in the workflow.

Make zizmor available on PATH to audit the workflows locally with the same pedantic persona.

Terminal window
composer zizmor

Zizmor needs GitHub API access for its online audits. Use the offline flag to run without API access.

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

CI runs PHP 8.3, 8.4, and 8.5 separately with Yii 2.0.55 (the minimum supported release) and 22.0.x-dev. To repeat either resolution locally, use separate disposable checkouts so their dependencies and lock files cannot affect each other:

Terminal window
composer update --with yiisoft/yii2:2.0.55 --with-all-dependencies
composer tests
composer audit

Repeat in the other checkout with --with yiisoft/yii2:22.0.x-dev. Keep advisory blocking enabled for both runs.

Worker session and response lifecycle tests

Section titled “Worker session and response lifecycle tests”

To focus on worker session and response lifecycle regressions:

Terminal window
composer tests -- tests/http/stateless/ApplicationSessionTest.php
composer tests -- tests/http/stateless/ApplicationFinalizeTest.php

Validate the application’s actual worker integration too: alternate two visitors, omit cookies on the next request, send malformed session cookie values, exercise an upload followed by no upload, and force emission failure. Confirm after-send runs only after successful emission. Repeat with useSession=false when using lazy sessions.

Report the PHP version, resolved dependencies, passed checks, and unavailable coverage/runtime tests rather than treating a skipped check as passed.

See agent validation stages for skill installation and native discovery checks.

Back to documentation