Skip to content
PHP Ecosystem
Explore

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:

Run Rector to apply automated code refactoring. This command modifies files.

Terminal window
composer rector

Preview the refactoring without modifying files.

Terminal window
composer rector-check

Check coding standards without modifying files.

Terminal window
composer ecs-check

Apply coding standard fixes. Review the changes before keeping them.

Terminal window
composer ecs

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

Terminal window
composer check-dependencies

Run mutation testing.

Terminal window
composer mutation

Run mutation testing with PHPStan static analysis enabled.

Terminal window
composer mutation-static

Thresholds, thread count and memory options live in infection.json5. CI enforces the same thresholds.

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:

Terminal window
composer actionlint

Run static analysis.

Terminal window
composer static

Run the full test suite.

Terminal window
composer tests

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:

Terminal window
composer zizmor

Zizmor needs GitHub API access for its online audits. If the tool runs offline, report that limit separately. To request an offline audit explicitly:

Terminal window
composer zizmor -- --offline

Report hosted CI execution and its PHP/OS matrix separately from these local commands. Keep generated reports in ignored internal/.

Composer scripts support forwarding additional arguments using --.

Run PHPUnit with code coverage report generation.

Terminal window
composer tests -- --coverage-html internal/coverage

Run PHPStan with a different memory limit.

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

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 Stryker Vitest runner supports Vitest 5’s > test-name separator.

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

Back to documentation