SonataAdminBundleTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\SonataAdminBundle;
  15. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  16. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  17. /**
  18. * Test for SonataAdminBundle.
  19. *
  20. * @author Andrej Hudec <pulzarraider@gmail.com>
  21. */
  22. class SonataAdminBundleTest extends \PHPUnit_Framework_TestCase
  23. {
  24. public function testBuild()
  25. {
  26. $containerBuilder = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
  27. $containerBuilder->expects($this->exactly(3))
  28. ->method('addCompilerPass')
  29. ->will($this->returnCallback(function (CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) {
  30. if ($pass instanceof AddDependencyCallsCompilerPass) {
  31. return;
  32. }
  33. if ($pass instanceof AddFilterTypeCompilerPass) {
  34. return;
  35. }
  36. if ($pass instanceof ExtensionCompilerPass) {
  37. return;
  38. }
  39. $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)));
  40. }));
  41. $bundle = new SonataAdminBundle();
  42. $bundle->build($containerBuilder);
  43. }
  44. }