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.

Tool references:

The Testo configuration lives in testo.php: the Unit suite reads tests/Unit and the Bench suite reads tests/Bench. The Git compatibility cases live in tests/Fixtures/git-cases.json: each one stores two line lists and the edit operations of git diff --no-index -U100000 run without user or system configuration (GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1), since a configured diff.algorithm changes the result.

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

Run the benchmarks that measure LineDiffer on its own and behind UnifiedDiffRenderer on the same generated input.

Terminal window
composer bench

The script runs testo --type=bench. Timings depend on the machine and the PHP version, so compare results from the same run.

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 with PHPStan static analysis enabled. Infection runs the Testo suites through testo/bridge-infection. This is the command CI runs.

Terminal window
composer mutation-static

Run mutation testing without static analysis.

Terminal window
composer mutation

Both runs reach the required score without ignored mutants. Thresholds, thread count and memory options live in infection.json5; the package requires a 100 % mutation score indicator (MSI). CI enforces the same thresholds.

Make the CLI tools used by the shared quality workflow available on PATH: actionlint with its ShellCheck helper, codespell, EditorConfig Checker, markdownlint-cli2, Prettier and yamllint. Run all checks:

Terminal window
composer quality

Each tool also has its own script:

Terminal window
composer actionlint
composer codespell
composer editorconfig-checker
composer markdownlint
composer prettier
composer yamllint

The linter configuration lives in .github/linters, and the Prettier configuration in .prettierrc.json and .prettierignore. CI uses the same files.

Run static analysis at level max.

Terminal window
composer static

Run the test suites without the benchmarks.

Terminal window
composer tests

The script runs testo --type=!bench. CI runs the same command on PHP 8.3, 8.4 and 8.5, on Ubuntu and Windows, and uploads the coverage to Codecov.

Filter the tests by class or method name (the match is case-sensitive), and print a single JSON summary with the failed tests instead of the terminal report.

Terminal window
vendor/bin/testo --json --filter=LineDifferTest
vendor/bin/testo --json --filter=matchesGitEditOperations

Collect coverage with PCOV or Xdebug enabled and write a Clover XML report.

Terminal window
vendor/bin/testo --coverage-clover=runtime/clover.xml

Make zizmor and Gitleaks available on PATH. Audit the current workflow files with the same pedantic persona used by the shared security workflow:

Terminal window
composer zizmor

Scan Git history for secrets with the repository’s Gitleaks configuration:

Terminal window
composer gitleaks

Run both checks. Findings make the command fail; inspect them rather than disabling the checks.

Terminal window
composer security

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 runtime/ or internal/.

Composer scripts support forwarding additional arguments using --.

Run the Testo suites with a Clover coverage report.

Terminal window
composer tests -- --coverage-clover=runtime/clover.xml

Run only the tests of one suite.

Terminal window
composer tests -- --suite=Unit

Run PHPStan with a different memory limit.

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

Back to documentation