This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php

56 lines
1.7 KiB
PHP
Raw Normal View History

<?php
2015-09-26 13:14:16 +01:00
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass;
/**
* @author Wouter J <wouter@wouterj.nl>
*/
class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase
{
private $container;
private $pass;
protected function setUp()
{
2016-12-19 09:02:29 +00:00
$this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
$this->pass = new ExtensionCompilerPass();
}
public function testProcess()
{
$extension1 = $this->createExtensionMock(true);
$extension1->expects($this->once())->method('process');
$extension2 = $this->createExtensionMock(false);
$extension3 = $this->createExtensionMock(false);
$extension4 = $this->createExtensionMock(true);
$extension4->expects($this->once())->method('process');
$this->container->expects($this->any())
->method('getExtensions')
->will($this->returnValue(array($extension1, $extension2, $extension3, $extension4)))
;
$this->pass->process($this->container);
}
private function createExtensionMock($hasInlineCompile)
{
2016-12-19 09:02:29 +00:00
return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
$hasInlineCompile
? 'Compiler\CompilerPassInterface'
: 'Extension\ExtensionInterface'
2016-12-19 09:02:29 +00:00
))->getMock();
}
}