PHPackages                             dragonmantank/alliance - 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. dragonmantank/alliance

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

dragonmantank/alliance
======================

PHPUnit extension to add database functionality

21PHP

Since Jan 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/dragonmantank/alliance)[ Packagist](https://packagist.org/packages/dragonmantank/alliance)[ RSS](/packages/dragonmantank-alliance/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Alliance
========

[](#alliance)

Alliance is a PHPUnit extension that adds in functionality for using a database in integration and functional testing. This will clean and run database migrations automatically between test runs, and provides additional assertions for checking data inside of the database.

This extension is *not* meant to be a replacement for unit tests, but as a compliment for when actual database testing needs to be done. Tests that use Alliance will be slower than traditional unit tests.

Installation
------------

[](#installation)

Installation is done via [Composer](https://getcomposer.org) and should be added as a dev requirement:

```
composer require --dev dragonmantank/alliance
```

Alliance requires PHPUnit 8.0 and PHP 7.2 or higher.

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

[](#configuration)

Alliance is configured through a combination of the `phpunit.xml` file for your project as well as the configuration settings your migration library already uses. This allows you to maintain your DB settings in an expected location for your application, and Alliance will ingest that to do it's job.

For the most part, you will need to add a new `` block to your `phpunit.xml` file, and modify the configuration options. Each migration library plugin will have its own set of configuration.

More information can be found in the ["Configuring Extensions"](https://phpunit.readthedocs.io/en/8.5/extending-phpunit.html#configuring-extensions)portion of the PHPUnit Manual.

### Configuring Phinx

[](#configuring-phinx)

```

            phinx

                phinx.yml

                testing

```

Usage
-----

[](#usage)

All you need to do is have your extend `Alliance\DbTestCase` instead of `PHPUnit\Framework\TestCase`. This will allow the extension to detect that it needs to run the database mechanisms.

```
namespace MyAppTest;

use Alliance\DbTestCase;

class FooTest extends DbTestCase
{

}
```

`Alliance\DbTestCase` will expose some database-specific assertions that you can then use in your tests.

### New Assertions

[](#new-assertions)

#### `assertNotInTable(string $table, array $query)`

[](#assertnotintablestring-table-array-query)

Make sure that a specified row does not exist in the specified table. `$query`is an array of columns and values that will be used to build an AND query to check for the row.

```
$this->assertNotInTable('posts', ['title' => 'My Post title']);
```

#### `assertSingleRowInTable(string $table, array $query)`

[](#assertsinglerowintablestring-table-array-query)

Make sure that a specified row does exist as a single row in the specified table. `$query` is an array of columns and values that will be used to build an AND query to check for the row.

Multiple rows that match the query will cause this assertion to fail, so make sure your query is as specific as possible.

```
$this->assertSingleRowInTable(
    'posts',
    [
        'id' => $post->id,
        'title' => $post->title,
        'slug' => $post->slug
    ]
);
```

Supported Migration Libraries
-----------------------------

[](#supported-migration-libraries)

- [phinx](https://github.com/cakephp/phinx)

License
-------

[](#license)

Licensed under the [Apache License 2.0](LICENSE.md)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c2583b67d4e1a4ade23b6ce271980d18bf3facb4ea3f0610fded770f380d17d?d=identicon)[dragonmantank](/maintainers/dragonmantank)

---

Top Contributors

[![dragonmantank](https://avatars.githubusercontent.com/u/108948?v=4)](https://github.com/dragonmantank "dragonmantank (3 commits)")

### Embed Badge

![Health badge](/badges/dragonmantank-alliance/health.svg)

```
[![Health](https://phpackages.com/badges/dragonmantank-alliance/health.svg)](https://phpackages.com/packages/dragonmantank-alliance)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M678](/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.8M753](/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.0k](/packages/orchestra-testbench)

PHPackages © 2026

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