Testing
Ta treść nie jest jeszcze dostępna w Twoim języku.
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”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.
composer staticUnit tests (PHPUnit)
Section titled “Unit tests (PHPUnit)”Run the full test suite.
composer testsThe test classes are grouped with #[Group] attributes: asset, form, html, i18n, item, and widget.
Workflow 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 PHPUnit with code coverage report generation.
composer tests -- --coverage-html internal/coverageRun a single test group.
composer tests -- --group formRun PHPStan with a different memory limit.
composer static -- --memory-limit=512MPrerequisites
Section titled “Prerequisites”The asset tests publish the real bootstrap and bootstrap-icons packages from the package node_modules directory.
composer install runs php-forge/foxy with the native manager, which installs
them from the root package.json using PHP and ext-zlib; Node.js is unnecessary for this step:
composer installKeep the development foxy.lock when updating frontend dependencies. It is excluded from Composer distribution archives
because consuming applications resolve their own frontend requirements and maintain their own lockfiles. Foxy also adds
generated @composer-asset/* dependencies with local file: paths to the checkout’s root package.json. Keep those
generated entries local: the distributed manifest must declare only registry packages, so it can be consumed without
paths into this checkout’s vendor directory. Inspect git diff -- package.json after Composer operations and remove
generated entries before committing or packaging the library.