PHPackages                             richcongress/unit-bundle - 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. [Framework](/categories/framework)
4. /
5. richcongress/unit-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

richcongress/unit-bundle
========================

A unit bundle for Symfony 4+

v1.0.2(6y ago)18.1k1[1 issues](https://github.com/rich-id/unit-bundle/issues)[1 PRs](https://github.com/rich-id/unit-bundle/pulls)MITPHPPHP &gt;=7.3

Since Feb 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/rich-id/unit-bundle)[ Packagist](https://packagist.org/packages/richcongress/unit-bundle)[ RSS](/packages/richcongress-unit-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (21)Versions (8)Used By (0)

Getting Started With RichCongressUnitBundle
===========================================

[](#getting-started-with-richcongressunitbundle)

This version of the bundle requires Symfony 4.4+ and PHP 7.3+.

[![Package version](https://camo.githubusercontent.com/3b391c9fa0e8eb29aeda9b945406d7e6d6a1fe5a10bc24cfc6bff85c97af3a9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696368636f6e67726573732f756e69742d62756e646c65)](https://packagist.org/packages/richcongress/unit-bundle)[![Build Status](https://camo.githubusercontent.com/5400e6868cf80cb9385effd87c9dff8405f4655985e6321aa6e65f58465ac102/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72696368636f6e67726573732f756e69742d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/richcongress/unit-bundle?branch=master)[![Coverage Status](https://camo.githubusercontent.com/e325c7888840342582eddddb3649e069d37298919efda89b5c4b3033cdbb4734/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f72696368636f6e67726573732f756e69742d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/richcongress/unit-bundle?branch=master)[![contributions welcome](https://camo.githubusercontent.com/9e93e892d0685e1bf7a1d0bd7c8410d6ecf2086a0a7b48dd58a6b96fa556ea2a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/richcongress/unit-bundle/issues)[![License](https://camo.githubusercontent.com/4141875b9db06b6e19ee4c8c4f14f34b47dabb4fcdad7816e338a79666b0aacb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d7265642e737667)](LICENSE.md)

The unit-bundle provides is suite for application testing. It provides wrappers to isolate tests, various test cases to avoid code redundancy and a easy fixtures management.

This bundle is a fork of the [chaplean/unit-bundle](https://github.com/chaplean/unit-bundle).

Quick start
===========

[](#quick-start)

The unit-bundle requires almost no configuration but provides useful tools to test your code. Here is an basic example:

```
class MainControllerTest extends ControllerTestCase
{
    /**
     * @WithFixtures
     *
     * @return void
     */
    public function testIndex(): void
    {
        $client = self::createClient();
        $client->request('GET', '/');

        self::assertStatusCode(Response::HTTP_OK, $client);
    }

    /**
     * @WithFixtures
     *
     * @return void
     */
    public function testUserEdition(): void
    {
        $client = $this->createClientWith('user-1');
        $client->request('PUT', '/rest/users/self', ['name' => 'Karl']);

        self::assertStatusCode(Response::HTTP_OK, $client);

        $content = self::getJsonContent($client);
        self::assertArrayKeyExists('name', $content);
        self::assertSame('Karl', $content['name']);
    }
}
```

Table of content
================

[](#table-of-content)

1. [Installation](#1-installation)
2. [Getting started](#2-getting-started)
    - [Configuration](Docs/Configuration.md)
    - [Available test cases](Docs/TestCases.md)
        - [CommandTestCase](Docs/TestCases.md#commandtestcase)
        - [ConstraintTestCase](Docs/TestCases.md#constrainttestcase)
        - [ControllerTestCase](Docs/TestCases.md#controllertestcase)
        - [RepositoryTestCase](Docs/TestCases.md#repositorytestcase)
        - [VoterTestCase](Docs/TestCases.md#votertestcase)
    - [Using the annotations](Docs/Annotations.md)
    - [Creating fixtures](Docs/TestFixtures.md)
    - [Overriding services with stub services](Docs/OverrideServices.md#overriding-services-with-stub-services)
    - [Use dynamic mocks (legacy)](Docs/OverrideServices.md#use-dynamic-mocks-legacy)
    - [Available default service stubs](Docs/OverrideServices.md#available-default-service-stubs)
    - [Role provider](Docs/RolesProvider.md)
3. [Versioning](#3-versioning)
4. [Contributing](#4-contributing)
5. [Hacking](#5-hacking)
6. [License](#6-license)

1. Installation
===============

[](#1-installation)

This version of the bundle requires Symfony 4.4+ and PHP 7.3+.

### 1.1 Composer

[](#11-composer)

```
composer require richcongress/unit-bundle
```

### 1.2 Bundles declaration

[](#12-bundles-declaration)

After the installation, make sure that those 4 bundles are declared correctly within the Kernel's bundles list.

```
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['test' => true],
new Liip\FunctionalTestBundle\LiipFunctionalTestBundle::class    => ['test' => true],
new Liip\TestFixturesBundle\LiipTestFixturesBundle::class        => ['test' => true],
new RichCongress\Bundle\UnitBundle\RichCongressUnitBundle::class => ['test' => true],
```

1.3 Declare the PHP Extension
-----------------------------

[](#13-declare-the-php-extension)

First and foremost, declare the PHPUnitExtension in the `phpunit.xml.dist`:

```
...

...
```

1.4 Mandatory configuration
---------------------------

[](#14-mandatory-configuration)

By default, the bundle configures everything on its own but if the config has been overriden somewhere, you can override it back to the default by importing the configuration:

```
imports:
    - { resource: '@RichCongressUnitBundle/Resources/config/config.yml' }
```

Or configure manually doctrine with something like this:

```
parameters:
    doctrine.dbal.connection_factory.class: Liip\TestFixturesBundle\Factory\ConnectionFactory

doctrine:
    dbal:
        driver: pdo_sqlite
        user: test
        path: '%kernel.cache_dir%/test.db'
        url: null
        memory: false
```

2. Getting started
==================

[](#2-getting-started)

- [Configuration](Docs/Configuration.md)
- [Available test cases](Docs/TestCases.md)
    - [CommandTestCase](Docs/TestCases.md#commandtestcase)
    - [ConstraintTestCase](Docs/TestCases.md#constrainttestcase)
    - [ControllerTestCase](Docs/TestCases.md#controllertestcase)
    - [RepositoryTestCase](Docs/TestCases.md#repositorytestcase)
    - [VoterTestCase](Docs/TestCases.md#votertestcase)
- [Using the annotations](Docs/Annotations.md)
- [Creating fixtures](Docs/TestFixtures.md)
- [Overriding services with stub services](Docs/OverrideServices.md#overriding-services-with-stub-services)
- [Use dynamic mocks (legacy)](Docs/OverrideServices.md#use-dynamic-mocks-legacy)
- [Available default service stubs](Docs/OverrideServices.md#available-default-service-stubs)
- [Role provider](Docs/RolesProvider.md)

3. Versioning
=============

[](#3-versioning)

unit-bundle follows [semantic versioning](https://semver.org/). In short the scheme is MAJOR.MINOR.PATCH where

1. MAJOR is bumped when there is a breaking change,
2. MINOR is bumped when a new feature is added in a backward-compatible way,
3. PATCH is bumped when a bug is fixed in a backward-compatible way.

Versions bellow 1.0.0 are considered experimental and breaking changes may occur at any time.

4. Contributing
===============

[](#4-contributing)

Contributions are welcomed! There are many ways to contribute, and we appreciate all of them. Here are some of the major ones:

- [Bug Reports](https://github.com/richcongress/unit-bundle/issues): While we strive for quality software, bugs can happen and we can't fix issues we're not aware of. So please report even if you're not sure about it or just want to ask a question. If anything the issue might indicate that the documentation can still be improved!
- [Feature Request](https://github.com/richcongress/unit-bundle/issues): You have a use case not covered by the current api? Want to suggest a change or add something? We'd be glad to read about it and start a discussion to try to find the best possible solution.
- [Pull Request](https://github.com/richcongress/unit-bundle/merge_requests): Want to contribute code or documentation? We'd love that! If you need help to get started, GitHub as [documentation](https://help.github.com/articles/about-pull-requests/) on pull requests. We use the ["fork and pull model"](https://help.github.com/articles/about-collaborative-development-models/) were contributors push changes to their personnal fork and then create pull requests to the main repository. Please make your pull requests against the `master` branch.

As a reminder, all contributors are expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md).

5. Hacking
==========

[](#5-hacking)

You might use Docker and `docker-compose` to hack the project. Check out the following commands.

```
# Start the project
docker-compose up -d

# Install dependencies
docker-compose exec application composer install

# Run tests
docker-compose exec application bin/phpunit

# Run a bash within the container
docker-compose exec application bash
```

6. License
==========

[](#6-license)

unit-bundle is distributed under the terms of the MIT license.

See [LICENSE](LICENSE.md) for details.

###  Health Score

25

↓

LowBetter than 37% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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 ~142 days

Total

4

Last Release

1868d ago

Major Versions

v1.0.2 → v2.0.0.x-dev2021-04-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/6bfb5e4a3dde826e4cd3f92d24fdfbdce1415c77f3edd38fc3420b4988977e13?d=identicon)[HugoDumazeau](/maintainers/HugoDumazeau)

![](https://www.gravatar.com/avatar/8084ee0162a85df3b3f49230b8c0dde81108195caa541bb00642cbd050e88b25?d=identicon)[hudumazeau](/maintainers/hudumazeau)

---

Top Contributors

[![NicolasGuilloux](https://avatars.githubusercontent.com/u/4090627?v=4)](https://github.com/NicolasGuilloux "NicolasGuilloux (30 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

symfonysymfony-bundlesymfony4test-driven-developmenttesting-tools

### Embed Badge

![Health badge](/badges/richcongress-unit-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/richcongress-unit-bundle/health.svg)](https://phpackages.com/packages/richcongress-unit-bundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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