init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
|
|
@ -0,0 +1,73 @@
|
|||
<?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 Sensio\Bundle\FrameworkExtraBundle\Tests\DependencyInjection;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class AddExpressionLanguageProvidersPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var AddExpressionLanguageProvidersPass
|
||||
*/
|
||||
private $pass;
|
||||
|
||||
/**
|
||||
* @var ContainerBuilder
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @var Definition
|
||||
*/
|
||||
private $expressionLangDefinition;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->pass = new AddExpressionLanguageProvidersPass();
|
||||
$this->container = new ContainerBuilder();
|
||||
$this->expressionLangDefinition = new Definition();
|
||||
$this->container->setDefinition('sensio_framework_extra.security.expression_language.default', $this->expressionLangDefinition);
|
||||
}
|
||||
|
||||
public function testProcessNoOpNoExpressionLang()
|
||||
{
|
||||
$this->container->removeDefinition('sensio_framework_extra.security.expression_language.default');
|
||||
$this->pass->process($this->container);
|
||||
}
|
||||
|
||||
public function testProcessNoOpNoTaggedServices()
|
||||
{
|
||||
$this->pass->process($this->container);
|
||||
$this->assertCount(0, $this->expressionLangDefinition->getMethodCalls());
|
||||
}
|
||||
|
||||
public function testProcessAddsTaggedServices()
|
||||
{
|
||||
$provider = new Definition();
|
||||
$provider->setTags(array(
|
||||
'security.expression_language_provider' => array(
|
||||
array(),
|
||||
),
|
||||
));
|
||||
|
||||
$this->container->setDefinition('provider', $provider);
|
||||
|
||||
$this->pass->process($this->container);
|
||||
|
||||
$methodCalls = $this->expressionLangDefinition->getMethodCalls();
|
||||
$this->assertCount(1, $methodCalls);
|
||||
$this->assertEquals(array('registerProvider', array(new Reference('provider'))), $methodCalls[0]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?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 Sensio\Bundle\FrameworkExtraBundle\Tests\DependencyInjection;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\Compiler\AddParamConverterPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class AddParamConverterPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var AddParamConverterPass
|
||||
*/
|
||||
private $pass;
|
||||
|
||||
/**
|
||||
* @var ContainerBuilder
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @var Definition
|
||||
*/
|
||||
private $managerDefinition;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->pass = new AddParamConverterPass();
|
||||
$this->container = new ContainerBuilder();
|
||||
$this->managerDefinition = new Definition();
|
||||
$this->container->setDefinition('sensio_framework_extra.converter.manager', $this->managerDefinition);
|
||||
}
|
||||
|
||||
public function testProcessNoOpNoManager()
|
||||
{
|
||||
$this->container->removeDefinition('sensio_framework_extra.converter.manager');
|
||||
$this->pass->process($this->container);
|
||||
}
|
||||
|
||||
public function testProcessNoOpNoTaggedServices()
|
||||
{
|
||||
$this->pass->process($this->container);
|
||||
$this->assertCount(0, $this->managerDefinition->getMethodCalls());
|
||||
}
|
||||
|
||||
public function testProcessAddsTaggedServices()
|
||||
{
|
||||
$paramConverter1 = new Definition();
|
||||
$paramConverter1->setTags(array(
|
||||
'request.param_converter' => array(
|
||||
array(
|
||||
'priority' => 'false',
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
$paramConverter2 = new Definition();
|
||||
$paramConverter2->setTags(array(
|
||||
'request.param_converter' => array(
|
||||
array(
|
||||
'converter' => 'foo',
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
$paramConverter3 = new Definition();
|
||||
$paramConverter3->setTags(array(
|
||||
'request.param_converter' => array(
|
||||
array(
|
||||
'priority' => 5,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
$this->container->setDefinition('param_converter_one', $paramConverter1);
|
||||
$this->container->setDefinition('param_converter_two', $paramConverter2);
|
||||
$this->container->setDefinition('param_converter_three', $paramConverter3);
|
||||
|
||||
$this->pass->process($this->container);
|
||||
|
||||
$methodCalls = $this->managerDefinition->getMethodCalls();
|
||||
$this->assertCount(3, $methodCalls);
|
||||
$this->assertEquals(array('add', array(new Reference('param_converter_one'), 0, null)), $methodCalls[0]);
|
||||
$this->assertEquals(array('add', array(new Reference('param_converter_two'), 0, 'foo')), $methodCalls[1]);
|
||||
$this->assertEquals(array('add', array(new Reference('param_converter_three'), 5, null)), $methodCalls[2]);
|
||||
}
|
||||
}
|
||||
124
vendor/sensio/framework-extra-bundle/Tests/DependencyInjection/SensioFrameworkExtraExtensionTest.php
vendored
Normal file
124
vendor/sensio/framework-extra-bundle/Tests/DependencyInjection/SensioFrameworkExtraExtensionTest.php
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<?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 Sensio\Bundle\FrameworkExtraBundle\Tests\DependencyInjection;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\SensioFrameworkExtraExtension;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\Compiler\LegacyPass;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
|
||||
class SensioFrameworkExtraExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacySecurityListener()
|
||||
{
|
||||
if (interface_exists('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config'));
|
||||
$loader->load('security.xml');
|
||||
$r = new \ReflectionClass('Symfony\Bundle\SecurityBundle\SecurityBundle');
|
||||
$loader = new XmlFileLoader($container, new FileLocator(dirname($r->getFileName()).'/Resources/config'));
|
||||
$loader->load('security.xml');
|
||||
$this->registerLegacyPass($container);
|
||||
$container->compile();
|
||||
|
||||
$securityContext = $container->getDefinition('sensio_framework_extra.security.listener')->getArgument(0);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $securityContext);
|
||||
}
|
||||
|
||||
public function testSecurityListener()
|
||||
{
|
||||
if (!interface_exists('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config'));
|
||||
$loader->load('security.xml');
|
||||
$r = new \ReflectionClass('Symfony\Bundle\SecurityBundle\SecurityBundle');
|
||||
$loader = new XmlFileLoader($container, new FileLocator(dirname($r->getFileName()).'/Resources/config'));
|
||||
$loader->load('security.xml');
|
||||
$this->registerLegacyPass($container);
|
||||
$container->compile();
|
||||
|
||||
$this->assertNull($container->getDefinition('sensio_framework_extra.security.listener')->getArgument(0));
|
||||
}
|
||||
|
||||
public function testDefaultExpressionLanguageConfig()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$extension = new SensioFrameworkExtraExtension();
|
||||
$extension->load(array(), $container);
|
||||
|
||||
$this->assertAlias($container, 'sensio_framework_extra.security.expression_language.default', 'sensio_framework_extra.security.expression_language');
|
||||
}
|
||||
|
||||
public function testOverrideExpressionLanguageConfig()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$extension = new SensioFrameworkExtraExtension();
|
||||
$config = array(
|
||||
'security' => array(
|
||||
'expression_language' => 'acme.security.expression_language',
|
||||
),
|
||||
);
|
||||
|
||||
$container->setDefinition('acme.security.expression_language', new Definition());
|
||||
|
||||
$extension->load(array($config), $container);
|
||||
|
||||
$this->assertAlias($container, 'acme.security.expression_language', 'sensio_framework_extra.security.expression_language');
|
||||
}
|
||||
|
||||
public function testTemplatingControllerPatterns()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$extension = new SensioFrameworkExtraExtension();
|
||||
$config = array(
|
||||
'templating' => array(
|
||||
'controller_patterns' => $patterns = array('/foo/', '/bar/', '/foobar/'),
|
||||
),
|
||||
);
|
||||
|
||||
$extension->load(array($config), $container);
|
||||
|
||||
$this->assertEquals($patterns, $container->getDefinition('sensio_framework_extra.view.guesser')->getArgument(1));
|
||||
}
|
||||
|
||||
private function assertAlias(ContainerBuilder $container, $value, $key)
|
||||
{
|
||||
$this->assertEquals($value, (string) $container->getAlias($key), sprintf('%s alias is correct', $key));
|
||||
}
|
||||
|
||||
private function registerLegacyPass(ContainerBuilder $container)
|
||||
{
|
||||
$passConfig = $container->getCompiler()->getPassConfig();
|
||||
$passConfig->setAfterRemovingPasses(array());
|
||||
$passConfig->setBeforeOptimizationPasses(array());
|
||||
$passConfig->setBeforeRemovingPasses(array());
|
||||
$passConfig->setOptimizationPasses(array());
|
||||
$passConfig->setRemovingPasses(array());
|
||||
$container->addCompilerPass(new LegacyPass());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue