Files
iTop/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php
Molkobain 5960dc6245 N°2435.1 Portal: Split portal composer.json in 2
- Autoloader for portal files in the itop-portal-base module
- Dependencies moved to root composer.json
- Add autoloader for /core and /application content
2019-08-13 10:34:22 +02:00

46 lines
1.7 KiB
PHP

<?php
/*
* 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\Bundle\TwigBundle\Tests\DependencyInjection\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class TwigEnvironmentPassTest extends TestCase
{
public function testTwigBridgeExtensionsAreRegisteredFirst()
{
$container = new ContainerBuilder();
$twigDefinition = $container->register('twig');
$container->register('other_extension', 'Foo\Bar')
->addTag('twig.extension');
$container->register('twig_bridge_extension', FormExtension::class)
->addTag('twig.extension');
$twigEnvironmentPass = new TwigEnvironmentPass();
$twigEnvironmentPass->process($container);
$methodCalls = $twigDefinition->getMethodCalls();
$this->assertCount(2, $methodCalls);
$twigBridgeExtensionReference = $methodCalls[0][1][0];
$this->assertInstanceOf(Reference::class, $twigBridgeExtensionReference);
$this->assertSame('twig_bridge_extension', (string) $twigBridgeExtensionReference);
$otherExtensionReference = $methodCalls[1][1][0];
$this->assertInstanceOf(Reference::class, $otherExtensionReference);
$this->assertSame('other_extension', (string) $otherExtensionReference);
}
}