PHPackages                             cspray/database-test-case - 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-test-case

Abandoned → [cspray/database-testing](/?search=cspray%2Fdatabase-testing)Library[Testing &amp; Quality](/categories/testing)

cspray/database-test-case
=========================

A framework-agnostic library for setting up a database suitable for automated testing.

0.5.0(1y ago)42991[4 issues](https://github.com/cspray/database-testing/issues)[1 PRs](https://github.com/cspray/database-testing/pulls)MITPHPPHP ^8.3CI failing

Since Mar 2Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/cspray/database-testing)[ Packagist](https://packagist.org/packages/cspray/database-test-case)[ RSS](/packages/cspray-database-test-case/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (3)Versions (11)Used By (0)

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

[](#cspraydatabase-testing)

A low-level, framework-agnostic library for setting up a database suitable for automated tests. This library provides the following features:

- The `Cspray\DatabaseTesting\ConnectionAdapter` interface that defines how this library, and those that extend it, interact with your database.
- Comprehensive, customizable strategies for cleaning up your database to ensure each test works with a known state.
- Declare fixtures, sets of database records, that are loaded for each test.
- A simple interface to easily introspect the contents of a database table in your test suite.
- Database and testing-framework agnostic approach

It cannot be emphasized enough; this library does not provide a turn-key, usable solution out-of-the-box. If you use this library directly, instead of one of the extensions that targets a specific database connection and testing framework, you'll need to ensure the appropriate concrete implementations and framework integration points are created.

Complete Libraries
------------------

[](#complete-libraries)

Instead of installing this library directly, we recommend that you install one of the available options from the "Connection Adapter" and "Testing Extension" list. Chances are, you'll need both. If you don't see your database connection type or testing framework listed, please submit an issue to this repository!

### Connection Adapter

[](#connection-adapter)

- [cspray/database-testing-pdo](https://github.com/cspray/database-testing-pdo)

### Testing Extension

[](#testing-extension)

- [cspray/database-testing-phpunit](https://github.com/cspray/database-testing-phpunit)

Quick Example
-------------

[](#quick-example)

This example is intended to reflect what should be capable with this library. We're going to use [cspray/database-testing-phpunit](https://github.com/cspray/databse-testing-phpunit) as our testing extension, it is ubiquitous and likely the framework you'll start off using with this library.

```
