Salta ai contenuti
PHP Ecosystem
Explore

Testing

Questi contenuti non sono ancora disponibili nella tua lingua.

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

Neither Rector nor ECS is needed to reformat Markdown-only changes.

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; retain the configured 100% mutation thresholds. Run mutation tests when relevant to runtime work; an unchanged runtime does not need a fresh mutation run merely because documentation or skill instructions changed.

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.

Terminal window
composer static

Run the full test suite.

Terminal window
composer tests

CI runs zizmor and Gitleaks through the shared security workflow. Gitleaks uses its default rules. 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 a single PHPUnit test class.

Terminal window
composer tests -- --filter ManagerTest

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

Use PHP 8.3 or later and the dependencies in the repository’s composer.json:

Terminal window
composer install
composer validate --strict
composer check-platform-reqs

CI runs PHPUnit on PHP 8.3, 8.4, 8.5, and 8.6 with gd, intl, and sodium. CI ignores Composer platform requirements only when installing dependencies on PHP 8.6. Each job runs against Yii 2.0.55 and 22.0.x-dev. The PHP suite uses PHPUnit 12.5 and the installed Yii/core revisions. Keep an application lockfile when verifying an integration; this library’s lockfile is ignored.

Review the configuration and application recipes, then run the consuming application’s own checks.

ManagerTest covers validation/flash lifetime across requests, asset conflicts, page encoding, and response headers; RequestTest covers signed CSRF handling, and BootstrapTest covers write redirects.

For application acceptance, additionally mount the actual client, navigate between two pages, submit a valid and an invalid form, inspect the cookie/header exchange, resolve deferred UI, and retry with an outdated asset version. Record server and browser evidence separately.

Lint application-owned PHP snippets explicitly when adapting the guide recipes.


AI assistance · Back to documentation