SonataAdminBundleTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
  12. use Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass;
  13. use Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass;
  14. use Sonata\AdminBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass;
  15. use Sonata\AdminBundle\SonataAdminBundle;
  16. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  17. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  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->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
  28. ->setMethods(array('addCompilerPass'))
  29. ->getMock();
  30. $containerBuilder->expects($this->exactly(4))
  31. ->method('addCompilerPass')
  32. ->will($this->returnCallback(function (CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) {
  33. if ($pass instanceof AddDependencyCallsCompilerPass) {
  34. return;
  35. }
  36. if ($pass instanceof AddFilterTypeCompilerPass) {
  37. return;
  38. }
  39. if ($pass instanceof ExtensionCompilerPass) {
  40. return;
  41. }
  42. if ($pass instanceof GlobalVariablesCompilerPass) {
  43. return;
  44. }
  45. $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)));
  46. }));
  47. $bundle = new SonataAdminBundle();
  48. $bundle->build($containerBuilder);
  49. }
  50. }