From a8ee4094b42d643c280732999747bc4e56c42fe1 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Fri, 3 Jun 2011 08:42:11 +0200 Subject: [PATCH] Register CompilerPass in Bundle and add test --- ...gisterEventListenersAndSubscribersPass.php | 2 +- DoctrineCouchDBBundle.php | 10 +++++- Tests/BundleTest.php | 32 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Tests/BundleTest.php diff --git a/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php b/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php index 6dce71c..9567412 100644 --- a/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php +++ b/DependencyInjection/Compiler/RegisterEventListenersAndSubscribersPass.php @@ -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; diff --git a/DoctrineCouchDBBundle.php b/DoctrineCouchDBBundle.php index eb8a937..4ec2b51 100644 --- a/DoctrineCouchDBBundle.php +++ b/DoctrineCouchDBBundle.php @@ -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); + } } \ No newline at end of file diff --git a/Tests/BundleTest.php b/Tests/BundleTest.php new file mode 100644 index 0000000..ee1e413 --- /dev/null +++ b/Tests/BundleTest.php @@ -0,0 +1,32 @@ + + * + * 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); + } +} \ No newline at end of file