Atomic uses PHPUnit 10.x.
From the project root:
vendor/bin/phpunit -c tests/phpunit.xmlIn environments where result-cache writes are undesirable:
vendor/bin/phpunit -c tests/phpunit.xml --do-not-cache-resultRun one file:
vendor/bin/phpunit -c tests/phpunit.xml tests/Engine/Core/CryptoTest.phpRun one test method:
vendor/bin/phpunit -c tests/phpunit.xml --filter test_encrypt_decrypt_roundtripOptional text coverage when Xdebug or PCOV is available:
vendor/bin/phpunit -c tests/phpunit.xml --coverage-textThe full suite expects local MySQL, Redis, and Memcached services to be reachable with the defaults from tests/phpunit.xml.
Create the dedicated MySQL test user and database:
mysql -u root -pThen run:
CREATE USER IF NOT EXISTS 'atomic_test_user'@'localhost' IDENTIFIED BY 'atomic_test_pass';
CREATE USER IF NOT EXISTS 'atomic_test_user'@'127.0.0.1' IDENTIFIED BY 'atomic_test_pass';
CREATE DATABASE IF NOT EXISTS atomic_test CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON atomic_test.* TO 'atomic_test_user'@'localhost';
GRANT ALL PRIVILEGES ON atomic_test.* TO 'atomic_test_user'@'127.0.0.1';
FLUSH PRIVILEGES;Quick connectivity checks:
mysql -u atomic_test_user -patomic_test_pass -D atomic_test -e "SELECT CURRENT_USER(), DATABASE();"
redis-cli ping
echo stats | nc 127.0.0.1 11211tests/phpunit.xml currently sets:
bootstrap="bootstrap.php"cacheDirectory=".phpunit.cache"colors="true"failOnRisky="true"failOnIncomplete="true"failOnWarning="true"displayDetailsOnTestsThatTriggerWarnings="true"
The configured test suite is:
Engine->tests/Engine
The configured source include path is:
engine/Atomic
tests/bootstrap.php does more than autoloading. It:
- resolves the framework root from
tests/.. - defines the core
ATOMIC_*constants used by the framework during tests - loads Composer autoloading and framework helpers
- creates temporary
LOGSandTEMPdirectories under the system temp directory - seeds
REDISandMEMCACHEDhive config with test defaults - seeds
DB_CONFIGfrom PHPUnit environment defaults - connects the shared
DBhandle used by DB-backed tests - ensures the DB-backed cache tables exist in
atomic_test - enables debug mode with:
DEBUG_MODE=trueDEBUG_LEVEL=debugDEBUG=3
- sets:
HALT=falseQUIET=true
tests/phpunit.xml provides default DB environment values:
DB_HOST=127.0.0.1DB_PORT=3306DB_DB=atomic_testDB_USERNAME=atomic_test_userDB_PASSWORD=atomic_test_pass
Override them in CI or your shell when your database test environment differs.
PHPUnit is bootstrapped with the custom extension:
Tests\Support\PassFailPrinter
That changes console output formatting only; it does not replace PHPUnit's core execution flow.
Examples present in this repository:
- core utilities such as
Crypto,Guard,Prefly,Request,Response,RouteLoader, andSanitizer - plugin manager behavior
- queue telemetry manager filtering
- theme assets and schema helpers
- nonce behavior
Notes:
CryptoTestskips itself if the Sodium extension is unavailable.- Several tests use reflection to reset singletons between cases.
- Many subsystem tests are unit-level and avoid external services by mocking or by seeding hive config only.
- Run with
-c tests/phpunit.xmlso bootstrap and suite selection stay aligned with the repository. - Expect temp logs and temp files to be created under the OS temp directory during tests.
- Use the dedicated MySQL test account from
tests/phpunit.xml, or overrideDB_HOST,DB_PORT,DB_DB,DB_USERNAME, andDB_PASSWORDin your shell or CI. - If you are working in a read-only or ephemeral environment, use
--do-not-cache-result.