PHPackages                             ecomdev/mysql-test-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ecomdev/mysql-test-utils

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ecomdev/mysql-test-utils
========================

Bare minimum MySQL Test utilities for writing automated tests of software that relies on MySQL as data storage.

1.0.0(5y ago)04[1 PRs](https://github.com/EcomDev/mysql-test-utils/pulls)MITPHPCI passing

Since Jun 9Pushed 1mo agoCompare

[ Source](https://github.com/EcomDev/mysql-test-utils)[ Packagist](https://packagist.org/packages/ecomdev/mysql-test-utils)[ RSS](/packages/ecomdev-mysql-test-utils/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

MySQL Test Utilities
====================

[](#mysql-test-utilities)

Bare minimum MySQL Test utilities for writing automated tests of software that relies on MySQL as data storage.

This package works great with any type of MySQL setup as soon as user for testing can create own databases. Each instance of the database class creates a new unique database on the server that gets dropped upon test case completion.

Configuration
-------------

[](#configuration)

In your PHPUnit xml you need to specify the connection settings for mysql connection and executable for mysql client.

Down below is an example of phpunit xml configuration with docker-compose database setup.

```

        tests/

```

```
version: "3"
services:
  mysql:
    image: percona/percona-server:5.7
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: tests
```

Examples
--------

[](#examples)

#### Database gets created on each test

[](#database-gets-created-on-each-test)

```
use PHPUnit\Framework\TestCase;
use EcomDev\MySQLTestUtils\DatabaseFactory;

class SomeDatabaseRelatedTest extends TestCase
{
    private $database;

    protected function setUp() : void
    {
         $this->database = (new DatabaseFactory())->createDatabase();
         $this->database->loadFixture('some/path/to/schema.sql');
    }

    public function testSomethingIsWritten()
    {
        $this->assertEquals(
            [
                ['value1', 'value2']
            ],
            $this->database->fetchTable('some_table_name', 'column1', 'column2')
        );
    }
}
```

#### Database gets created on each test class

[](#database-gets-created-on-each-test-class)

```
use PHPUnit\Framework\TestCase;
use EcomDev\MySQLTestUtils\DatabaseFactory;

class SomeDatabaseRelatedTest extends TestCase
{
    private static $database;

    public static function setUpBeforeClass() : void
    {
         self::$database = (new DatabaseFactory())->createDatabase();
         self::$database->loadFixture('some/path/to/schema.sql');
    }

    public static function tearDownAfterClass() : void
    {
         self::$database = null;
    }

    public function testSomethingIsWritten()
    {
        $this->assertEquals(
            [
                ['value1', 'value2']
            ],
            self::$database->fetchTable('some_table_name', 'column1', 'column2')
        );
    }
}
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance61

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2169d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/190d12eae43e0d874394cbc7fc49ea94c6b6e1bc8b05f75b94fbd0b9c4b5d15f?d=identicon)[IvanChepurnyi](/maintainers/IvanChepurnyi)

---

Top Contributors

[![IvanChepurnyi](https://avatars.githubusercontent.com/u/866758?v=4)](https://github.com/IvanChepurnyi "IvanChepurnyi (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ecomdev-mysql-test-utils/health.svg)

```
[![Health](https://phpackages.com/badges/ecomdev-mysql-test-utils/health.svg)](https://phpackages.com/packages/ecomdev-mysql-test-utils)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
