The project has three test suites configured in phpunit.xml.dist:
-
default - Unit tests only
- Excludes integration tests
- Fast execution
- No external dependencies required
-
integration - Integration tests only
- Requires MODX installation or mocked environment
- Most tests are skipped unless
MODX_INTEGRATION_TESTS=1is set
-
all - Complete test suite
- Includes both unit and integration tests
- Recommended for comprehensive testing
./vendor/bin/phpunit
# or explicitly:
./vendor/bin/phpunit --testsuite default./vendor/bin/phpunit --testsuite integrationMODX_INTEGRATION_TESTS=1 ./vendor/bin/phpunit -c phpunit.integration.xml./vendor/bin/phpunit --testsuite allXDEBUG_MODE=coverage ./vendor/bin/phpunit --testsuite all --coverage-html=var/coverage/htmlXDEBUG_MODE=coverage ./vendor/bin/phpunit --testsuite default --coverage-html=var/coverage/htmlXDEBUG_MODE=coverage ./vendor/bin/phpunit --testsuite all --coverage-textXDEBUG_MODE=coverage ./vendor/bin/phpunit --testsuite allThis generates:
- HTML report:
var/coverage/html/index.html - Text report:
var/coverage/coverage.txt - Clover XML:
var/coverage/clover.xml
Test counts change as coverage expands. Use the PHPUnit output (or --list-tests) for current totals.
Solution: Make sure you're using --testsuite all to run both unit and integration tests.
Reason: Integration tests require a live MODX environment or the MODX_INTEGRATION_TESTS=1 flag.
Solution: Set the environment variable:
MODX_INTEGRATION_TESTS=1 ./vendor/bin/phpunit --testsuite integrationSolution: Run coverage on unit tests only:
XDEBUG_MODE=coverage ./vendor/bin/phpunit --testsuite defaultopen var/coverage/html/index.html
# or on Linux:
xdg-open var/coverage/html/index.htmlcat var/coverage/coverage.txt