Testing
این محتوا هنوز به زبان شما در دسترس نیست.
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:
- Composer Require Checker for dependency definition checks.
- Easy Coding Standard (ECS) for coding standards.
- Infection for mutation testing.
- PHPStan for static analysis.
- PHPUnit for unit tests.
- Rector for automated refactoring.
- Vitest with jsdom for JavaScript unit tests.
- StrykerJS for JavaScript mutation testing.
- esbuild for minified assets.
Automated refactoring (Rector)
Section titled “Automated refactoring (Rector)”Run Rector to apply automated code refactoring.
composer rectorCoding standards (ECS)
Section titled “Coding standards (ECS)”Run Easy Coding Standard (ECS) and apply fixes.
composer ecsDependency definition check
Section titled “Dependency definition check”Verify that runtime dependencies are correctly declared in composer.json.
composer check-dependenciesJavaScript 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 pretest:mutation npm hook temporarily adapts Stryker 10.0.0’s test-name filtering to Vitest 5’s
> separator. It runs
automatically with the command above, including after a clean npm ci. The versioned patch checks the installed
runner version, Vitest major version, and both helper copies before changing anything; repeated runs are safe.
Unexpected versions or helper content stop the run so dependency upgrades cannot silently keep a stale patch.
Remove the hook and tools/patch-stryker-vitest5.mjs after upgrading to an official runner with verified Vitest 5
filtering support. The patch changes only the installed test runner; coverage and mutation thresholds stay at 100%.
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 buildMutation testing (Infection)
Section titled “Mutation testing (Infection)”Run mutation testing.
composer mutationRun mutation testing with static analysis enabled.
composer mutation-staticStatic 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 testsPassing 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 code_coverageRun PHPStan with a different memory limit.
composer static -- --memory-limit=512M