4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Tests\Compiler;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass;
18 * @author Wouter J <wouter@wouterj.nl>
20 class ExtensionCompilerPassTest extends TestCase
25 protected function setUp()
27 $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
28 $this->pass = new ExtensionCompilerPass();
31 public function testProcess()
33 $extension1 = $this->createExtensionMock(true);
34 $extension1->expects($this->once())->method('process');
35 $extension2 = $this->createExtensionMock(false);
36 $extension3 = $this->createExtensionMock(false);
37 $extension4 = $this->createExtensionMock(true);
38 $extension4->expects($this->once())->method('process');
40 $this->container->expects($this->any())
41 ->method('getExtensions')
42 ->will($this->returnValue(array($extension1, $extension2, $extension3, $extension4)))
45 $this->pass->process($this->container);
48 private function createExtensionMock($hasInlineCompile)
50 return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
52 ? 'Compiler\CompilerPassInterface'
53 : 'Extension\ExtensionInterface'