ExtensionCompilerPassTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\DependencyInjection\Tests\Compiler;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass;
  13. /**
  14. * @author Wouter J <wouter@wouterj.nl>
  15. */
  16. class ExtensionCompilerPassTest extends TestCase
  17. {
  18. private $container;
  19. private $pass;
  20. protected function setUp()
  21. {
  22. $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
  23. $this->pass = new ExtensionCompilerPass();
  24. }
  25. public function testProcess()
  26. {
  27. $extension1 = $this->createExtensionMock(true);
  28. $extension1->expects($this->once())->method('process');
  29. $extension2 = $this->createExtensionMock(false);
  30. $extension3 = $this->createExtensionMock(false);
  31. $extension4 = $this->createExtensionMock(true);
  32. $extension4->expects($this->once())->method('process');
  33. $this->container->expects($this->any())
  34. ->method('getExtensions')
  35. ->will($this->returnValue(array($extension1, $extension2, $extension3, $extension4)))
  36. ;
  37. $this->pass->process($this->container);
  38. }
  39. private function createExtensionMock($hasInlineCompile)
  40. {
  41. return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
  42. $hasInlineCompile
  43. ? 'Compiler\CompilerPassInterface'
  44. : 'Extension\ExtensionInterface'
  45. ))->getMock();
  46. }
  47. }