Testing
Bu içerik henüz dilinizde mevcut değil.
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.
- Infection for mutation testing.
- Markdownlint-cli2 for Markdown linting.
- 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-dependenciesMutation testing (Infection)
Section titled “Mutation testing (Infection)”Run mutation testing.
composer mutationRun mutation testing with PHPStan static analysis enabled.
composer mutation-staticThresholds, thread count and memory options live in infection.json5. CI enforces the same thresholds.
Repository quality checks
Section titled “Repository quality checks”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:
composer qualityEach tool also has its own script:
composer actionlintcomposer codespellcomposer editorconfig-checkercomposer markdownlintcomposer prettiercomposer yamllintThe linter configuration lives in .github/linters, and the Prettier configuration in .prettierrc.json and
.prettierignore. CI uses the same files.
Static analysis (PHPStan)
Section titled “Static analysis (PHPStan)”Run static analysis.
composer staticUnit tests (PHPUnit)
Section titled “Unit tests (PHPUnit)”Run the full test suite.
composer testsWorkflow security checks
Section titled “Workflow security checks”Make zizmor and Gitleaks available on PATH. Audit the current workflow files with the same pedantic persona used by
the shared security workflow:
composer zizmorScan Git history for secrets with the repository’s Gitleaks configuration:
composer gitleaksRun both checks. Findings make the command fail; inspect them rather than disabling the checks.
composer securityZizmor needs GitHub API access for its online audits. If the tool runs offline, report that limit separately. To request an offline audit explicitly:
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 PHPUnit with code coverage report generation.
composer tests -- --coverage-html internal/coverageRun PHPStan with a different memory limit.
composer static -- --memory-limit=512MCI matrix and Yii resolution
Section titled “CI matrix and Yii resolution”The build workflow runs PHPUnit on PHP 8.3, 8.4, 8.5 and 8.6 on Ubuntu and Windows with the intl, mbstring and
sodium extensions, once per supported Yii line: the phpunit job resolves Yii 22.0.x-dev and the
phpunit-compatibility job resolves Yii 2.0.55 (the minimum supported release). Both jobs change the requirement with
composer require yiisoft/yii2:<version> before running the suite. CI passes --ignore-platform-reqs to Composer only
on PHP 8.6. The mutation test workflow still runs Infection with PHPStan on PHP 8.3.
To repeat either resolution locally, use separate disposable checkouts so their dependencies and lock files cannot affect each other:
composer require yiisoft/yii2:2.0.55 --with-all-dependenciescomposer testsRepeat in the other checkout with yiisoft/yii2:22.0.x-dev.
Worker lifecycle tests
Section titled “Worker lifecycle tests”phpunit.xml.dist loads the package’s internal-function mocks. The suite uses the real bridge lifecycle and a
deterministic Yii response. It verifies request limits, HEAD body suppression, emission before after-send, successive
requests, failed emission/conversion, and finalization once when after-send throws.
These tests run under PHP CLI; they do not start FrankenPHP. To verify a deployment, use the quick start with the installed runtime and run the migration checks. Check native request reset, session isolation, upload reset, HEAD headers/body, partial-download bytes, and worker restarts. Record the runtime version and distinguish this evidence from mocked unit results.
Documentation checks
Section titled “Documentation checks”Run the format tools over the guides and skill files after editing them:
composer markdownlintcomposer prettiercomposer editorconfig-checker