Bỏ qua để đến nội dung
PHP Ecosystem
Explore

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:

Run Rector to apply automated code refactoring.

Terminal window
composer rector

Run Easy Coding Standard (ECS) and apply fixes.

Terminal window
composer ecs

Verify that runtime dependencies are correctly declared in composer.json.

Terminal window
composer check-dependencies

Install the Node.js toolchain (see .nvmrc) and run the tests in tests/js with 100% line, branch, and function coverage thresholds.

Terminal window
npm ci
npm run test:js

Run mutation testing for the JavaScript sources (minimum score 100%).

Terminal window
npm run test:mutation

The 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%.

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.

Terminal window
npm run build

Run mutation testing.

Terminal window
composer mutation

Run mutation testing with static analysis enabled.

Terminal window
composer mutation-static

Run static analysis.

Terminal window
composer static

Run the full test suite.

Terminal window
composer tests

Composer scripts support forwarding additional arguments using --.

Run PHPUnit with code coverage report generation.

Terminal window
composer tests -- --coverage-html code_coverage

Run PHPStan with a different memory limit.

Terminal window
composer static -- --memory-limit=512M