Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Register CompilerPass in Bundle and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Jun 3, 2011
1 parent aa88030 commit a8ee409
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
Expand Up @@ -9,7 +9,7 @@
* with this source code in the file LICENSE.
*/

namespace Symfony\Bundle\DoctrineBundle\DependencyInjection\Compiler;
namespace Symfony\Bundle\DoctrineCouchDBBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
10 changes: 9 additions & 1 deletion DoctrineCouchDBBundle.php
Expand Up @@ -12,8 +12,16 @@
namespace Symfony\Bundle\DoctrineCouchDBBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\DoctrineCouchDBBundle\DependencyInjection\Compiler\RegisterEventListenersAndSubscribersPass;

class DoctrineCouchDBBundle extends Bundle
{

public function build(ContainerBuilder $container)
{
parent::build($container);

$container->addCompilerPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
}
}
32 changes: 32 additions & 0 deletions Tests/BundleTest.php
@@ -0,0 +1,32 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\DoctrineCouchDBBundle\Tests;

use Symfony\Bundle\DoctrineCouchDBBundle\DoctrineCouchDBBundle;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;

class BundleTest extends TestCase
{
public function testRegisterEventListener()
{
$bundle = new DoctrineCouchDBBundle();
$builder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
$builder->expects($this->once())
->method('addCompilerPass')
->with(
$this->isInstanceOf('Symfony\Bundle\DoctrineCouchDBBundle\DependencyInjection\Compiler\RegisterEventListenersAndSubscribersPass'),
$this->equalTo(PassConfig::TYPE_BEFORE_OPTIMIZATION)
);

$bundle->build($builder);
}
}

0 comments on commit a8ee409

Please sign in to comment.