PHPackages                             cspray/database-testing-phpunit - 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. cspray/database-testing-phpunit

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

cspray/database-testing-phpunit
===============================

A testing extension for cspray/database-testing to integrate with PHPUnit.

0.1.0(1y ago)314[1 issues](https://github.com/cspray/database-testing-phpunit/issues)[1 PRs](https://github.com/cspray/database-testing-phpunit/pulls)PHPPHP ^8.3CI passing

Since May 9Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/cspray/database-testing-phpunit)[ Packagist](https://packagist.org/packages/cspray/database-testing-phpunit)[ RSS](/packages/cspray-database-testing-phpunit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

cspray/database-testing-phpunit
===============================

[](#cspraydatabase-testing-phpunit)

A PHPUnit Extension for [cspray/database-testing](https://github.com/cspray/database-testing), designed to facilitate setting up a test database suitable for automated testing.

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

[](#installation)

Composer is the only supported method for installing this library.

```
composer require --dev cspray/database-testing-phpunit
```

Please note, it is highly likely you'll need a library that provides an implementation of `Cspray\DatabaseTesting\ConnectionAdapter\ConnectionAdapter`! This library does not come with the adapter appropriate for your database connection!

Review the tests!
-----------------

[](#review-the-tests)

If you're here to learn more about how to use `cspray/databse-testing` in your PHPUnit tests, check out the tests in this library! The `phpunit.xml` config and the implemented tests provide a working example on how to use it!

Quick Start
-----------

[](#quick-start)

The examples below uses a `ConnectionAdapter` and `ConnectionAdapterFactory` available from `cspray/database-testing-pdo`. If PDO is not an appropriate connection for your use case, please replace with the appropriate `ConnectionAdapter` implementation.

### Register your Extension

[](#register-your-extension)

The first step is to register the extension in your PHPUnit configuration. Ensure the following XML is present in `phpunit.xml` (or the file you use for you PHPUnit config).

```

```

### Attribute your TestCase

[](#attribute-your-testcase)

The next step is to add the `#[RequiresTestDatabase]` attribute to your PHPUnit TestCase. There's no inheritance or traits required, you don't need to change what `TestCase` you extend!

```
