Testing
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
This package provides a consistent set of Composer scripts for local validation, plus npm scripts for the JavaScript runtime and Cropper.js adapter.
These are package development checks. Keep the repository’s Foxy manager set to npm and use its Node.js toolchain for
Vitest, Stryker, and esbuild. Applications consuming the published extension can install its ready-to-serve assets with
Foxy’s native PHP manager; see installation. Native installation does not replace this development
toolchain.
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.
- esbuild for minified assets.
- 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.
- StrykerJS for JavaScript mutation testing.
- Vitest with jsdom for JavaScript unit tests.
- 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 quality
workflow. It uses the shared configuration with FilePond-specific spelling exceptions and EditorConfig Checker
exclusions for minified assets and the npm lockfile. The repository’s formatting rules remain in .editorconfig.
To lint workflows locally, make actionlint and ShellCheck available on PATH:
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 testsWorkflow security checks
Section titled “Workflow security checks”CI runs zizmor and Gitleaks through the shared security workflow. Gitleaks uses the default rules plus an allowlist for
the dummy credentials in the test fixture. The scan step is skipped if GITLEAKS_LICENSE is unavailable to the
workflow.
To audit workflow files locally with the same pedantic persona, make zizmor available on PATH:
composer zizmorZizmor 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=512MJavaScript tests (Vitest)
Section titled “JavaScript tests (Vitest)”Install the Node.js toolchain (see .nvmrc) and run the tests in tests/js with 100% line, branch, and function
coverage thresholds.
npm cinpm run test:jsRun mutation testing for the JavaScript sources (minimum score 100%).
npm run test:mutationThe Stryker Vitest runner supports Vitest 5’s
> test-name separator.
Minified assets
Section titled “Minified assets”Regenerate the committed *.min.js and *.min.css files after editing src/asset/widget or src/asset/cropper. The
assets workflow fails when the committed files differ from a fresh build.
npm run build