PHPackages                             facile-it/paraunit-testcase - 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. facile-it/paraunit-testcase

Abandoned → [dama/doctrine-test-bundle](/?search=dama%2Fdoctrine-test-bundle)ArchivedLibrary[Testing &amp; Quality](/categories/testing)

facile-it/paraunit-testcase
===========================

paraunit testcase

0.5.5(8y ago)623.4k1[4 issues](https://github.com/facile-it/paraunit-testcase/issues)Apache License Version 2.0PHP

Since Sep 8Pushed 8y ago2 watchersCompare

[ Source](https://github.com/facile-it/paraunit-testcase)[ Packagist](https://packagist.org/packages/facile-it/paraunit-testcase)[ Docs](http://github.com/facile-it/paraunit-testcase)[ RSS](/packages/facile-it-paraunit-testcase/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (17)Used By (0)

paraunit-testcase
=================

[](#paraunit-testcase)

**WARNING**: this package is now **abandoned**; we suggest [dama/doctrine-test-bundle](https://github.com/dmaicher/doctrine-test-bundle) as a replacement instead.

[![Stable release](https://camo.githubusercontent.com/a9796dc57bcee4be1b855148bbc0f05b99bd88246b3d29cf03599ec5d33770fc/68747470733a2f2f706f7365722e707567782e6f72672f666163696c652d69742f70617261756e69742d74657374636173652f76657273696f6e2e737667)](https://packagist.org/packages/facile-it/paraunit-testcase)[![Unstable release](https://camo.githubusercontent.com/855858fa3b0a138128852fb71c4d5e0c3468db73e7c9b99c04c9dbc584b4caa2/68747470733a2f2f706f7365722e707567782e6f72672f666163696c652d69742f70617261756e69742d74657374636173652f762f756e737461626c652e737667)](https://packagist.org/packages/facile-it/paraunit-testcase)

[![Scrutinizer](https://camo.githubusercontent.com/1417bbf9aaa4c4d6f39e0d2dd0c40199f6c9c7ca0bcedf2ff552e6bfb2b61f59/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f666163696c652d69742f70617261756e69742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/facile-it/paraunit/?branch=master)

TestCase and HTTP client to test Symfony2/3 applications with Doctrine database isolation:

- no more manual database cleanup after each test, it's already done!
- no more garbage left over in your test database
- mess all you want with your fixtures
- (a bit) faster functional tests

Requirements
------------

[](#requirements)

This package is meant to be used for functional testing inside Symfony2/3+Doctrine applications. It works only with transactional databases, so Entity Manager only, sorry!

If you need to test controllers that requires authentication, it's best to set the security to HTTP-basic in your test environment, to speed up the test and avoid re-testing the login functionality of your app; if this isn't viable for you, see **Advanced usage**.

It's suggested in combination with [facile-it/paraunit](https://github.com/facile-it/paraunit), for even more faster testing!

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

[](#installation)

To use this package, use composer:

- from CLI: `composer require --dev facile-it/paraunit-testcase`
- or, directly in your `composer.json`:

```
{
    "require-dev": {
        "facile-it/paraunit-testcase": "~0.4"
    }
}

```

Usage
-----

[](#usage)

This package provides a test case class, `ParaunitFunctionalTestCase`: to achieve **per-test-method transactional isolation**, extend you functional test classes from it.

With this, anything that your test writes on the DB:

- is normally readable everywhere inside your test method
- is "forgotten" at the end of the test method: the first-level transaction is always rolled back
- is faster to write (it doesn't really reach the DB)
- your app will behave normally: it can open and close more transactions, and it will fail as normal when flushing incorrect/incomplete data

### Testing a controller

[](#testing-a-controller)

The TestCase provides some utility methods for testing controller's actions:

- `getUnauthorizedClient()`: extended Symfony HTTP client, for controller testing (it can read inside the transaction, even between multiple requests)
- `getAuthorizedClient($user, $password)`: same as before, but with HTTP basic authentication
- `getEM()`: Doctrine's Entity Manager (transactional)
- `refreshEntity(&$entity, $entityManagerName = null)`: shortcut for refreshing an entity, re-fetching all the data from the database; really useful if you need to run some assertion on an entity and you want to be sure to read the data as persisted/rollbacked on the database.

### Testing a Console ContainerAwareCommand

[](#testing-a-console-containerawarecommand)

We also provide an easy way to test in parallel easily console `ContainerAwareCommand`. To do it use the the `ParaunitFunctionalTestCase::runContainerAwareCommandTester()` method, like this:

```
class YourCommandTest extends ParaunitFunctionalTestCase
{
    public function testYourCommand()
    {
        $output = $this->runContainerAwareCommandTester(
            new YourCommand(),
            [
                'argument' => 'argumentValue',
                '--option' => 0,
            ]
        );

        $this->assertContains('Execution completed', $output);
    }
}

```

If you want to split the instantiation and the execution (i.e. if you need to interact with the container first), you can use the `createContainerAwareCommandTester()` method to get a `ContainerAwareCommandTester` class like this:

```
class YourCommandTest extends ParaunitFunctionalTestCase
{
    public function testYourCommand()
    {
        $commandTester = $this->createContainerAwareCommandTester(new YourCommand());
        $container = $commandTester->getCommandContainer();
        // do what you want to the container!

        $commandTester->execute(
            [
                'argument' => 'argumentValue',
                '--option' => 0,
            ]
        );

        $this->assertEquals(0, $commandTester->getStatusCode());
        $this->assertContains('Execution completed', $commandTester->getDisplay());
    }
}

```

Note: the `ContainerAwareCommandTester` class which the method returns extends Symfony's `CommandTester` class, so you can use it in the same way (see the assertions); the only difference is that it provides the same level of transactional isolation as our test case or client.

\##Advanced usage It's possible to extend `ParaunitFunctionalTestCase` more before using it as your base test case:

- extend and use the `prepareAuthorizedClient(...)` hook method to add additional authentication and preparation to the client, if needed
- do NOT EVER FORGET to call the parent methods first if you override the `setUp()` and `tearDown()` methods

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 97% 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

Every ~51 days

Recently: every ~22 days

Total

14

Last Release

3240d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cd2707d7bc5233dac66a38db2af69d347c4c815ffb6ddbd9be27cd1eda37d14?d=identicon)[Jean85](/maintainers/Jean85)

---

Top Contributors

[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (65 commits)")[![ranpafin](https://avatars.githubusercontent.com/u/3133626?v=4)](https://github.com/ranpafin "ranpafin (2 commits)")

---

Tags

databasetest-symfonytestcasetransactionphpunitsymfonydoctrineisolationtransactionparallel testtest case

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/facile-it-paraunit-testcase/health.svg)

```
[![Health](https://phpackages.com/badges/facile-it-paraunit-testcase/health.svg)](https://phpackages.com/packages/facile-it-paraunit-testcase)
```

###  Alternatives

[dama/doctrine-test-bundle

Symfony bundle to isolate doctrine database tests and improve test performance

1.2k37.2M144](/packages/dama-doctrine-test-bundle)[lchrusciel/api-test-case

Perfect PHPUnit TestCase for JSON/XML API TDD with Symfony.

4115.5M63](/packages/lchrusciel-api-test-case)[matthiasnoback/symfony-config-test

Library for testing user classes related to the Symfony Config Component

1679.8M395](/packages/matthiasnoback-symfony-config-test)[mattiasgeniar/phpunit-query-count-assertions

A custom assertion for phpunit that allows you to count the amount of SQL queries used in a test. Can be used to enforce certain performance characteristics (ie: limit queries to X for a certain action).

160730.9k2](/packages/mattiasgeniar-phpunit-query-count-assertions)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)[derptest/phpmachinist

Testing object factory for PHP

3636.9k1](/packages/derptest-phpmachinist)

PHPackages © 2026

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