endroid/bundle-test

This package is abandoned and no longer maintained. The author suggests using the https://github.com/endroid/quality package instead.

Endroid Bundle Test

dev-master / 1.x-dev 2019-10-07 19:40 UTC

This package is auto-updated.

Last update: 2023-11-07 13:17:50 UTC


README

By endroid

Latest Stable Version Build Status Total Downloads Total Downloads License

Allows easy testing of bundle functionality like routes and services by providing a testing kernel and configuration and allowing to define additional configuration inside your bundle without the need for creating a custom kernel.

Installation

Use Composer to install the library.

$ composer require endroid/bundle-test --dev

Configuration

You can place your package, routing and bundle configuration in the tests/config folder like you would normally in a Symfony 3.4+ application. The library already contains some default libraries like the framework bundle, twig bundle, monolog etc. so you only need to include things that are necessary for your bundle.

Usage

Create a BundleTestCase to test your bundle like you would normally create a WebTestCase inside your application. The BundleTestCase automatically creates a kernel and loads the configuration from your tests/config directory.

<?php

use Endroid\BundleTest\BundleTestCase;

class HomeControllerTest extends BundleTestCase
{
    public function testInvoke()
    {
        $client = static::createClient();
        $client->request('GET', '/');
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
        $this->assertEquals('Home', $client->getCrawler()->filter('h1')->text());
    }
}

And run simple-phpunit to execute your tests.

$ vendor/bin/simple-phpunit

Versioning

Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.

License

This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.