PHPackages                             braincrafted/testing-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. [Testing &amp; Quality](/categories/testing)
4. /
5. braincrafted/testing-bundle

ActiveSymfony-bundle[Testing &amp; Quality](/categories/testing)

braincrafted/testing-bundle
===========================

Tools for testing Symfony2 bundles

v0.4.2(10y ago)211.8k14MITPHPPHP &gt;=5.3.3

Since May 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/braincrafted/testing-bundle)[ Packagist](https://packagist.org/packages/braincrafted/testing-bundle)[ Docs](http://github.com/braincrafted/testing-bundle)[ RSS](/packages/braincrafted-testing-bundle/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (7)Dependencies (5)Versions (16)Used By (4)

BraincraftedTestingBundle
=========================

[](#braincraftedtestingbundle)

Handcrafted in Vienna by [Florian Eckerstorfer](https://florian.ec).

About
-----

[](#about)

This bundle currently provides an abstract class to better isolate functional tests of Symfony2 applications. The `WebTestCase` class drops the schema, recreates it and loads all fixture files. Currently [DoctrineFixturesBundle](https://github.com/doctrine/DoctrineFixturesBundle) is a required dependency of this bundle.

At some point this bundle may contain other useful classes, services and helpers related to testing.

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

[](#installation)

You need to add bundle to your `composer.json` file:

```
{
    "require-dev": {
        "braincrafted/testing-bundle": "@stable"
    }
}
```

*Tip: You should replace `@stable` with a specific [version](https://github.com/braincrafted/testing-bundle/releases).*

### Compatibility

[](#compatibility)

TestingBundle is developed to always work with the latest version of Symfony. The following table helps you choose the right version of TestingBundle.

   Symfony version TestingBundle version     `v2.3.*` `v0.1.*`   `v2.4.*`-`v2.5.*` `v0.2.*`-`v0.3.*`   `v2.6+` `v0.4+`  The master branch has been updated to be compatible with Symfony 2.3. If you are using Symfony &lt;2.3 you can use the `0.1` branch.

Add the bundle to your kernel (only activate the bundle in the dev and test environment, you don't need to have it activated in the production environment):

```
// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        // ...
        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Braincrafted\Bundle\TestingBundle\BraincraftedTestingBundle($this);
            // ...
        }
        // ...
    }
    // ...
}
```

Usage
-----

[](#usage)

The test cases that you want isolate must extend `Braincrafted\Bundle\TestingBundle\Test\WebTestCase`.

```
// AcmeDemoBundle/Tests/DemoTest.php
namespace AcmeDemoBundle\Tests;

use Braincrafted\Bundle\TestingBundle\Test\WebTestCase;

class DemoTest extends WebTestCase
{
    // ...
}
```

By default `WebTestCase` provides a `setUp()` and a `tearDown()` method that boot respectively shut down the kernel. However, if you have your own `setUp()` and/or `tearDown()` methods in your test case you need to manually do this.

```
// AcmeDemoBundle/Tests/DemoTest.php
namespace AcmeDemoBundle\Tests;

use Braincrafted\Bundle\TestingBundle\Test\WebTestCase;

class DemoTest extends WebTestCase
{
    public function setUp()
    {
        $this->setUpKernel();
        // ...
    }

    public function tearDown()
    {
        $this->tearDownKernel();
        // ...
    }
}
```

If you require a client in your test case, you can use the `createClient()` method:

```
$client = $this->createClient();
```

`createClient()` will call `setUpKernel()` when no kernel is available at this point.

You can also access the dependency injection container of the kernel:

```
$container = $this->getContainer();
```

### Render Crawler HTML

[](#render-crawler-html)

The `WebTestCase` class also has an nice helper method that returns the HTML code of a crawler. You can use it in all test cases that subclass `Braincrafted\Bundle\TestingBundle\Test\WebTestCase`:

```
echo $this->renderCrawlerHtml($crawler);
```

### Testing Translation Keys

[](#testing-translation-keys)

`BraincraftedTestingBundle` installs an alternative translator that is only activated in the `test` environment. This translator returns the translation key instead of the translated text. That way you can use the translation keys in your functional tests instead of the translated text.

Change Log
----------

[](#change-log)

### Version 0.4.2 (15 February 2016)

[](#version-042-15-february-2016)

- `NoTranslator` implements empty `setConfigCacheFactory()` method for compatibility

### Version 0.4.1 (20 April 2015)

[](#version-041-20-april-2015)

- `NoTranslator` returns message catalogue

### Version 0.4 (6 February 2015)

[](#version-04-6-february-2015)

- Add compatibility with Symfony 2.6

### Version 0.3.3 (6 February 2015)

[](#version-033-6-february-2015)

- Update to `composer.json` to reflect that the `0.3` branch is not compatible with Symfony 2.6.

### Version 0.3.2 (26 October 2014)

[](#version-032-26-october-2014)

- [\#10](https://github.com/braincrafted/testing-bundle/pull/10) Try to find `AppKernel.php` in a standard path before falling back to `KERNEL_DIR` constant (by [florianeckerstorfer](https://github.com/florianeckerstorfer))

### Version 0.3.1 (25 August 2014)

[](#version-031-25-august-2014)

- Fixed type hint for `WebTestCase::createClient()` method
- Pass `$options` to `WebTestCase::createKernel()` in `WebTestCase::createClient()`

### Version 0.3 (18 November 2013)

[](#version-03-18-november-2013)

- Changed namespace to `Braincrafted`.

License
-------

[](#license)

### The MIT License (MIT)

[](#the-mit-license-mit)

Copyright (c) 2012-2015 Florian Eckerstorfer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~76 days

Recently: every ~94 days

Total

14

Last Release

3742d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a80f9fc61cd3a7d7779e8f120b458ca4d18fdd885d719bb77d3379b96bf714d9?d=identicon)[florianeckerstorfer](/maintainers/florianeckerstorfer)

---

Top Contributors

[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![ihsanfaisal](https://avatars.githubusercontent.com/u/2241173?v=4)](https://github.com/ihsanfaisal "ihsanfaisal (1 commits)")[![mhor](https://avatars.githubusercontent.com/u/4103719?v=4)](https://github.com/mhor "mhor (1 commits)")

---

Tags

testing

### Embed Badge

![Health badge](/badges/braincrafted-testing-bundle/health.svg)

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

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpunit/php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

8.9k892.4M1.5k](/packages/phpunit-php-code-coverage)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/phpunit-bridge

Provides utilities for PHPUnit, especially user deprecation notices management

2.5k201.2M4.2k](/packages/symfony-phpunit-bridge)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)

PHPackages © 2026

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