BundleTest.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Doctrine Bundle
  4. *
  5. * The code was originally distributed inside the Symfony framework.
  6. *
  7. * (c) Fabien Potencier <fabien@symfony.com>
  8. * (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
  9. *
  10. * For the full copyright and license information, please view the LICENSE
  11. * file that was distributed with this source code.
  12. */
  13. namespace Doctrine\Bundle\DoctrineBundle\Tests;
  14. use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\DoctrineValidationPass;
  15. use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
  16. use Symfony\Component\DependencyInjection\ContainerBuilder;
  17. use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
  18. class BundleTest extends \PHPUnit_Framework_TestCase
  19. {
  20. public function testBuildCompilerPasses()
  21. {
  22. $container = new ContainerBuilder();
  23. $bundle = new DoctrineBundle();
  24. $bundle->build($container);
  25. $config = $container->getCompilerPassConfig();
  26. $passes = $config->getBeforeOptimizationPasses();
  27. $foundEventListener = false;
  28. $foundValidation = false;
  29. foreach ($passes as $pass) {
  30. if ($pass instanceof RegisterEventListenersAndSubscribersPass) {
  31. $foundEventListener = true;
  32. } elseif ($pass instanceof DoctrineValidationPass) {
  33. $foundValidation = true;
  34. }
  35. }
  36. $this->assertTrue($foundEventListener, 'RegisterEventListenersAndSubcribersPass was not found');
  37. $this->assertTrue($foundValidation, 'DoctrineValidationPass was not found');
  38. }
  39. }