Yaffs site version 1.1
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / ExtensionCompilerPassTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DependencyInjection\Tests\Compiler;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass;
16
17 /**
18  * @author Wouter J <wouter@wouterj.nl>
19  */
20 class ExtensionCompilerPassTest extends TestCase
21 {
22     private $container;
23     private $pass;
24
25     protected function setUp()
26     {
27         $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
28         $this->pass = new ExtensionCompilerPass();
29     }
30
31     public function testProcess()
32     {
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');
39
40         $this->container->expects($this->any())
41             ->method('getExtensions')
42             ->will($this->returnValue(array($extension1, $extension2, $extension3, $extension4)))
43         ;
44
45         $this->pass->process($this->container);
46     }
47
48     private function createExtensionMock($hasInlineCompile)
49     {
50         return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
51             $hasInlineCompile
52             ? 'Compiler\CompilerPassInterface'
53             : 'Extension\ExtensionInterface'
54         ))->getMock();
55     }
56 }