<?php

namespace Devhelp\PiwikBundle;


class DevhelpPiwikBundleTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @var DevhelpPiwikBundle
     */
    private $bundle;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    private $container;

    protected function setUp()
    {
        $this->container = $this
            ->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
            ->disableOriginalConstructor()
            ->getMock();

        $this->bundle = new DevhelpPiwikBundle();
    }

    /**
     * @test
     */
    public function it_adds_compiler_passes()
    {
        $this->it_adds_compiler_passes_to_the_container();
        $this->when_bundle_is_built();
    }

    private function when_bundle_is_built()
    {
        $this->bundle->build($this->container);
    }

    private function it_adds_compiler_passes_to_the_container()
    {
        $this->container
            ->expects($this->at(0))
            ->method('addCompilerPass')
            ->with($this->callback(function ($object) {
                return get_class($object) == 'Devhelp\PiwikBundle\DependencyInjection\Compiler\AddPiwikClientDefinition';
            }));

        $this->container
            ->expects($this->at(1))
            ->method('addCompilerPass')
            ->with($this->callback(function ($object) {
                return get_class($object) == 'Devhelp\PiwikBundle\DependencyInjection\Compiler\InsertParamsServices';
            }));
    }
}

<?php

namespace Devhelp\PiwikBundle;

use Symfony\Component\DependencyInjection\ContainerBuilder;

class DevhelpPiwikBundleTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @var DevhelpPiwikBundle
     */
    private $bundle;

    /**
     * @var ContainerBuilder
     */
    private $container;

    protected function setUp()
    {
        $this->container = new ContainerBuilder();
        $this->bundle = new DevhelpPiwikBundle();
    }

    /**
     * @test
     */
    public function it_adds_compiler_passes_to_the_container()
    {
        $this->when_bundle_is_built();
        $this->then_compiler_passes_are_added();
    }

    private function when_bundle_is_built()
    {
        $this->bundle->build($this->container);
    }

    private function then_compiler_passes_are_added()
    {
        $passes = $this->container->getCompiler()->getPassConfig()->getBeforeOptimizationPasses();

        $classes = array_map(function ($pass) {
            return get_class($pass);
        }, $passes);

        $expectedPassClasses = array(
            'Devhelp\PiwikBundle\DependencyInjection\Compiler\AddPiwikClientDefinition',
            'Devhelp\PiwikBundle\DependencyInjection\Compiler\InsertParamsServices'
        );

        $this->assertEquals($expectedPassClasses, $classes);
    }
}

Revert "dependency removed from bundle test"
Revert "dependency removed from bundle test"

This reverts commit 119a99ec1947f49803e913e0220a1edc633feb6e.
