Testing
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
This package provides a consistent set of Composer scripts for local validation.
Tool references:
- Actionlint for GitHub Actions workflow linting.
- Codespell for spelling checks.
- Composer Require Checker for dependency definition checks.
- Easy Coding Standard (ECS) for coding standards.
- EditorConfig Checker for EditorConfig compliance.
- Gitleaks for secret scanning.
- Markdownlint-cli2 for Markdown linting.
- ParaTest for parallel PHPUnit execution.
- PHPStan for static analysis.
- PHPUnit for unit tests.
- Prettier for Markdown and YAML formatting checks.
- Rector for automated refactoring.
- Yamllint for YAML linting.
- Zizmor for GitHub Actions security audits.
Automated refactoring (Rector)
Section titled “Automated refactoring (Rector)”Run Rector to apply automated code refactoring. This command modifies files.
composer rectorPreview the refactoring without modifying files.
composer rector-checkCoding standards (ECS)
Section titled “Coding standards (ECS)”Check coding standards without modifying files.
composer ecs-checkApply coding standard fixes. Review the changes before keeping them.
composer ecsDependency definition check
Section titled “Dependency definition check”Verify that runtime dependencies are correctly declared in composer.json.
composer check-dependenciesRepository quality checks
Section titled “Repository quality checks”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.
composer actionlintStatic analysis (PHPStan)
Section titled “Static analysis (PHPStan)”Run static analysis with the Web application configuration (phpstan.neon).
composer staticRun static analysis with the console application configuration (phpstan-console.neon), matching the second CI job.
composer static-consoleStatic analysis targets PHP 8.3 and runs on PHP 8.3, 8.4, 8.5 and 8.6 in CI, with both configurations.
Unit tests (PHPUnit)
Section titled “Unit tests (PHPUnit)”Run the full type inference suite. The script runs PHPUnit through ParaTest, one worker process per CPU core, without a PHP memory limit.
composer testsLimit the number of worker processes when needed.
composer tests -- --processes=4Run a single test file with PHPUnit directly.
vendor/bin/phpunit tests/ServiceMapTest.phpWorkflow security checks
Section titled “Workflow security checks”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.
composer zizmorZizmor needs GitHub API access for its online audits. Use the offline flag to run without API access.
composer zizmor -- --offlineReport hosted CI execution and its PHP/OS matrix separately from these local commands. Keep generated reports in ignored
internal/.
Passing extra arguments
Section titled “Passing extra arguments”Composer scripts support forwarding additional arguments using --.
Run the suite with code coverage report generation.
composer tests -- --coverage-html internal/coverageRun PHPStan with a different memory limit.
composer static -- --memory-limit=512MInstall and audit
Section titled “Install and audit”Install the development dependencies in a source checkout and record the installed versions:
composer installcomposer validate --strictcomposer auditcomposer show yiisoft/yii2vendor/bin/phpstan --versionThe library’s lockfile is ignored; CI resolves dependencies for Yii 2.0.55 and Yii 22 on PHP 8.3, 8.4, 8.5 and 8.6. Only
the PHP 8.6 jobs pass --ignore-platform-reqs to Composer.
Package checks
Section titled “Package checks”PHPUnit compares inferred types through PHPStan\Testing\TypeInferenceTestCase, including configuration and cache
dependency cases. Both static configurations matter because Yii::$app has one configured application type per
analysis, so run both composer static and composer static-console.
The logger resolver looks up the optional Yii 22 yii\log\PsrMessage class by name and checks for it through reflection
before including it. The test bootstrap defines the expected payload type for the installed Yii version, so PHPUnit and
direct static checks validate the same fixture on Yii 2.0.55 and Yii 22. Retain the existence guard and both sets of
expectations when changing logger inference.
When checking an isolated consumer, preserve its composer.json and configured vendor directory together. PHPStan uses
that manifest to recognize dependency stubs; copying only the vendor tree can trigger project-stub validation.
Verify documented application setups
Section titled “Verify documented application setups”Adapt the usage recipes to the application and inspect the affected types. Run both Web and console analyses when relevant, and verify runtime behavior attachments or database/HTTP integration when they change.
For client discovery and activation, see AI assistance.