SonataAdminBundleTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Tests;
  11. use Sonata\AdminBundle\SonataAdminBundle;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  14. use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
  15. use Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass;
  16. use Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass;
  17. use Symfony\Component\DependencyInjection\ContainerBuilder;
  18. /**
  19. * Test for SonataAdminBundle
  20. *
  21. * @author Andrej Hudec <pulzarraider@gmail.com>
  22. */
  23. class SonataAdminBundleTest extends \PHPUnit_Framework_TestCase
  24. {
  25. public function testBuild()
  26. {
  27. $containerBuilder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('addCompilerPass'));
  28. $containerBuilder->expects($this->exactly(3))
  29. ->method('addCompilerPass')
  30. ->will($this->returnCallback(function (CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) {
  31. if ($pass instanceof AddDependencyCallsCompilerPass) {
  32. return;
  33. }
  34. if ($pass instanceof AddFilterTypeCompilerPass) {
  35. return;
  36. }
  37. if ($pass instanceof ExtensionCompilerPass) {
  38. return;
  39. }
  40. $this->fail(sprintf('Compiler pass is not one of the expected types. Expects "Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass", "Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass" or "Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass", but got "%s".', get_class($pass)));
  41. }));
  42. $bundle = new SonataAdminBundle();
  43. $bundle->build($containerBuilder);
  44. }
  45. }