PHPackages                             matthiasnoback/doctrine-dbal-test-service-provider - 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. matthiasnoback/doctrine-dbal-test-service-provider

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

matthiasnoback/doctrine-dbal-test-service-provider
==================================================

Service provider for tests in need of a Doctrine DBAL connection

v3.3.0(8mo ago)388.2k↓47.8%9[2 PRs](https://github.com/matthiasnoback/doctrine-dbal-test-service-provider/pulls)1MITPHPPHP ^7.1 || ^8.0CI passing

Since Dec 16Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/matthiasnoback/doctrine-dbal-test-service-provider)[ Packagist](https://packagist.org/packages/matthiasnoback/doctrine-dbal-test-service-provider)[ Docs](https://github.com/matthiasnoback/doctrine-dbal-test-service-provider)[ RSS](/packages/matthiasnoback-doctrine-dbal-test-service-provider/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (3)Versions (12)Used By (1)

Doctrine DBAL service provider for unit tests
=============================================

[](#doctrine-dbal-service-provider-for-unit-tests)

[![CI](https://github.com/matthiasnoback/doctrine-dbal-test-service-provider/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/matthiasnoback/doctrine-dbal-test-service-provider/actions/workflows/ci.yml)

This library contains a service provider to be used with a [service container for PHPUnit tests](https://github.com/matthiasnoback/phpunit-test-service-container).

Usage
-----

[](#usage)

Use the trait `Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithDoctrineDbalConnection` in your test class. You then need to implement the `createSchema()` and return an instance of `Doctrine\DBAL\Schema\Schema`.

For each test method a database connection (of instance `Doctrine\DBAL\Connection`) will be available. Also the schema returned by `createSchema()` will be created in the database. The database itself is (by default) an SQLite in-memory database, which will leave no traces on the filesystem.

```
