Lightweight PHPUnit MySQL test utilities that spin up isolated, unique per-test databases and drop them cleanly on teardown.

Overview

Shared test databases leak state between test cases and cause flaky ordering bugs. EcomDev/mysql-test-utils eliminates that problem with a minimal DatabaseFactory abstraction for PHPUnit.

Each test run provisions an isolated temporary database on your MySQL server, executes queries against a real storage engine, and drops the schema as soon as the test case completes.

Configuration Example

Configure your connection parameters in phpunit.xml:

<php>
    <env name="MYSQL_HOST" value="127.0.0.1" />
    <env name="MYSQL_USER" value="root" />
    <env name="MYSQL_PASSWORD" value="tests" />
    <env name="MYSQL_CLIENT" value="mysql" />
</php>

More in Automation Tools

View all Automation Tools →