Merge branch '2.6' into 2.7
* 2.6: [2.6] cleanup deprecated uses [2.5] cleanup deprecated uses Conflicts: src/Symfony/Component/Form/composer.json src/Symfony/Component/Security/Tests/Core/LegacySecurityContextInterfaceTest.php
This commit is contained in:
commit
1994cacd66
@ -265,6 +265,23 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
|
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLegacyInitShorthandEntityName()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$item1 = new SingleIntIdEntity(1, 'Foo');
|
||||||
|
$item2 = new SingleIntIdEntity(2, 'Bar');
|
||||||
|
|
||||||
|
$this->em->persist($item1);
|
||||||
|
$this->em->persist($item2);
|
||||||
|
|
||||||
|
$choiceList = new EntityChoiceList(
|
||||||
|
$this->em,
|
||||||
|
'SymfonyTestsDoctrine:SingleIntIdEntity'
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
|
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,9 @@ class UnloadedEntityChoiceListSingleIntIdTest extends AbstractEntityChoiceListSi
|
|||||||
{
|
{
|
||||||
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
|
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
|
||||||
|
{
|
||||||
|
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
|
||||||
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
||||||
use Symfony\Component\Validator\Validation;
|
use Symfony\Component\Validator\Validation;
|
||||||
use Symfony\Component\Validator\Validator;
|
|
||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +183,6 @@ class ModelChoiceListTest extends Propel1TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
|
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
|
||||||
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDifferentEqualObjectsAreChoosen()
|
public function testDifferentEqualObjectsAreChoosen()
|
||||||
@ -202,12 +201,58 @@ class ModelChoiceListTest extends Propel1TestCase
|
|||||||
|
|
||||||
$choosenItem = new Item(1, 'Foo');
|
$choosenItem = new Item(1, 'Foo');
|
||||||
|
|
||||||
$this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
|
|
||||||
$this->assertEquals(array('1'), $choiceList->getValuesForChoices(array($choosenItem)));
|
$this->assertEquals(array('1'), $choiceList->getValuesForChoices(array($choosenItem)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForNullChoices()
|
public function testLegacygetIndicesForChoices()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$item1 = new Item(1, 'Foo');
|
||||||
|
$item2 = new Item(2, 'Bar');
|
||||||
|
|
||||||
|
ItemQuery::$result = array(
|
||||||
|
$item1,
|
||||||
|
$item2,
|
||||||
|
);
|
||||||
|
|
||||||
|
$choiceList = new ModelChoiceList(
|
||||||
|
self::ITEM_CLASS,
|
||||||
|
'value',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLegacyDifferentEqualObjectsAreChoosen()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$item = new Item(1, 'Foo');
|
||||||
|
|
||||||
|
ItemQuery::$result = array(
|
||||||
|
$item,
|
||||||
|
);
|
||||||
|
|
||||||
|
$choiceList = new ModelChoiceList(
|
||||||
|
self::ITEM_CLASS,
|
||||||
|
'value',
|
||||||
|
array($item)
|
||||||
|
);
|
||||||
|
|
||||||
|
$choosenItem = new Item(1, 'Foo');
|
||||||
|
|
||||||
|
$this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLegacyGetIndicesForNullChoices()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$item = new Item(1, 'Foo');
|
$item = new Item(1, 'Foo');
|
||||||
$choiceList = new ModelChoiceList(
|
$choiceList = new ModelChoiceList(
|
||||||
self::ITEM_CLASS,
|
self::ITEM_CLASS,
|
||||||
|
@ -36,7 +36,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
|
|||||||
'form_div_layout.html.twig',
|
'form_div_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
));
|
));
|
||||||
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
|
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
|
||||||
|
|
||||||
$this->extension = new FormExtension($renderer);
|
$this->extension = new FormExtension($renderer);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
|
|||||||
'form_table_layout.html.twig',
|
'form_table_layout.html.twig',
|
||||||
'custom_widgets.html.twig',
|
'custom_widgets.html.twig',
|
||||||
));
|
));
|
||||||
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'));
|
$renderer = new TwigRenderer($rendererEngine, $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
|
||||||
|
|
||||||
$this->extension = new FormExtension($renderer);
|
$this->extension = new FormExtension($renderer);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Alias;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
@ -340,6 +341,23 @@ class XmlDescriptor extends Descriptor
|
|||||||
$serviceXML->setAttribute('factory-method', $definition->getFactoryMethod());
|
$serviceXML->setAttribute('factory-method', $definition->getFactoryMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($factory = $definition->getFactory()) {
|
||||||
|
$serviceXML->appendChild($factoryXML = $dom->createElement('factory'));
|
||||||
|
|
||||||
|
if (is_array($factory)) {
|
||||||
|
if ($factory[0] instanceof Reference) {
|
||||||
|
$factoryXML->setAttribute('service', (string) $factory[0]);
|
||||||
|
} elseif ($factory[0] instanceof Definition) {
|
||||||
|
throw new \InvalidArgumentException('Factory is not describable.');
|
||||||
|
} else {
|
||||||
|
$factoryXML->setAttribute('class', $factory[0]);
|
||||||
|
}
|
||||||
|
$factoryXML->setAttribute('method', $factory[1]);
|
||||||
|
} else {
|
||||||
|
$factoryXML->setAttribute('function', $factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$serviceXML->setAttribute('scope', $definition->getScope());
|
$serviceXML->setAttribute('scope', $definition->getScope());
|
||||||
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
|
$serviceXML->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
|
||||||
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
|
$serviceXML->setAttribute('synthetic', $definition->isSynthetic() ? 'true' : 'false');
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Alias;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
@ -98,8 +99,7 @@ class ObjectsProvider
|
|||||||
->setLazy(true)
|
->setLazy(true)
|
||||||
->setSynchronized(true)
|
->setSynchronized(true)
|
||||||
->setAbstract(true)
|
->setAbstract(true)
|
||||||
->setFactoryClass('Full\\Qualified\\FactoryClass')
|
->setFactory(array('Full\\Qualified\\FactoryClass', 'get')),
|
||||||
->setFactoryMethod('get'),
|
|
||||||
'definition_2' => $definition2
|
'definition_2' => $definition2
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->setSynthetic(true)
|
->setSynthetic(true)
|
||||||
@ -110,8 +110,7 @@ class ObjectsProvider
|
|||||||
->addTag('tag1', array('attr1' => 'val1', 'attr2' => 'val2'))
|
->addTag('tag1', array('attr1' => 'val1', 'attr2' => 'val2'))
|
||||||
->addTag('tag1', array('attr3' => 'val3'))
|
->addTag('tag1', array('attr3' => 'val3'))
|
||||||
->addTag('tag2')
|
->addTag('tag2')
|
||||||
->setFactoryService('factory.service')
|
->setFactory(array(new Reference('factory.service'), 'get')),
|
||||||
->setFactoryMethod('get'),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
<container>
|
<container>
|
||||||
<alias id="alias_1" service="service_1" public="true"/>
|
<alias id="alias_1" service="service_1" public="true"/>
|
||||||
<alias id="alias_2" service="service_2" public="false"/>
|
<alias id="alias_2" service="service_2" public="false"/>
|
||||||
<definition id="definition_1" class="Full\Qualified\Class1" factory-class="Full\Qualified\FactoryClass" factory-method="get" scope="container" public="true" synthetic="false" lazy="true" synchronized="true" abstract="true" file=""/>
|
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" synchronized="true" abstract="true" file="">
|
||||||
|
<factory class="Full\Qualified\FactoryClass" method="get"/>
|
||||||
|
</definition>
|
||||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
|
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
|
||||||
</container>
|
</container>
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
<container>
|
<container>
|
||||||
<alias id="alias_1" service="service_1" public="true"/>
|
<alias id="alias_1" service="service_1" public="true"/>
|
||||||
<alias id="alias_2" service="service_2" public="false"/>
|
<alias id="alias_2" service="service_2" public="false"/>
|
||||||
<definition id="definition_1" class="Full\Qualified\Class1" factory-class="Full\Qualified\FactoryClass" factory-method="get" scope="container" public="true" synthetic="false" lazy="true" synchronized="true" abstract="true" file=""/>
|
<definition id="definition_1" class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" synchronized="true" abstract="true" file="">
|
||||||
<definition id="definition_2" class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
<factory class="Full\Qualified\FactoryClass" method="get"/>
|
||||||
|
</definition>
|
||||||
|
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
||||||
|
<factory service="factory.service" method="get"/>
|
||||||
<tags>
|
<tags>
|
||||||
<tag name="tag1">
|
<tag name="tag1">
|
||||||
<parameter name="attr1">val1</parameter>
|
<parameter name="attr1">val1</parameter>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<container>
|
<container>
|
||||||
<definition id="definition_2" class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
||||||
|
<factory service="factory.service" method="get"/>
|
||||||
<tags>
|
<tags>
|
||||||
<tag name="tag1">
|
<tag name="tag1">
|
||||||
<parameter name="attr1">val1</parameter>
|
<parameter name="attr1">val1</parameter>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<container>
|
<container>
|
||||||
<tag name="tag1">
|
<tag name="tag1">
|
||||||
<definition id="definition_2" class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file"/>
|
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
||||||
|
<factory service="factory.service" method="get"/>
|
||||||
|
</definition>
|
||||||
</tag>
|
</tag>
|
||||||
<tag name="tag2">
|
<tag name="tag2">
|
||||||
<definition id="definition_2" class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file"/>
|
<definition id="definition_2" class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
||||||
|
<factory service="factory.service" method="get"/>
|
||||||
|
</definition>
|
||||||
</tag>
|
</tag>
|
||||||
</container>
|
</container>
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<definition class="Full\Qualified\Class1" factory-class="Full\Qualified\FactoryClass" factory-method="get" scope="container" public="true" synthetic="false" lazy="true" synchronized="true" abstract="true" file=""/>
|
<definition class="Full\Qualified\Class1" scope="container" public="true" synthetic="false" lazy="true" synchronized="true" abstract="true" file="">
|
||||||
|
<factory class="Full\Qualified\FactoryClass" method="get"/>
|
||||||
|
</definition>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<definition class="Full\Qualified\Class2" factory-service="factory.service" factory-method="get" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
<definition class="Full\Qualified\Class2" scope="container" public="false" synthetic="true" lazy="false" synchronized="false" abstract="false" file="/path/to/file">
|
||||||
|
<factory service="factory.service" method="get"/>
|
||||||
<tags>
|
<tags>
|
||||||
<tag name="tag1">
|
<tag name="tag1">
|
||||||
<parameter name="attr1">val1</parameter>
|
<parameter name="attr1">val1</parameter>
|
||||||
|
@ -26,8 +26,10 @@ class GlobalVariablesTest extends TestCase
|
|||||||
$this->globals = new GlobalVariables($this->container);
|
$this->globals = new GlobalVariables($this->container);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSecurity()
|
public function testLegacyGetSecurity()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
$securityContext = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
|
||||||
|
|
||||||
$this->assertNull($this->globals->getSecurity());
|
$this->assertNull($this->globals->getSecurity());
|
||||||
|
@ -12,33 +12,37 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
|
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
|
||||||
|
|
||||||
class SessionHelperTest extends \PHPUnit_Framework_TestCase
|
class SessionHelperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected $request;
|
protected $requestStack;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->request = new Request();
|
$request = new Request();
|
||||||
|
|
||||||
$session = new Session(new MockArraySessionStorage());
|
$session = new Session(new MockArraySessionStorage());
|
||||||
$session->set('foobar', 'bar');
|
$session->set('foobar', 'bar');
|
||||||
$session->getFlashBag()->set('notice', 'bar');
|
$session->getFlashBag()->set('notice', 'bar');
|
||||||
|
|
||||||
$this->request->setSession($session);
|
$request->setSession($session);
|
||||||
|
|
||||||
|
$this->requestStack = new RequestStack();
|
||||||
|
$this->requestStack->push($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
$this->request = null;
|
$this->requestStack = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFlash()
|
public function testFlash()
|
||||||
{
|
{
|
||||||
$helper = new SessionHelper($this->request);
|
$helper = new SessionHelper($this->requestStack);
|
||||||
|
|
||||||
$this->assertTrue($helper->hasFlash('notice'));
|
$this->assertTrue($helper->hasFlash('notice'));
|
||||||
|
|
||||||
@ -47,13 +51,13 @@ class SessionHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetFlashes()
|
public function testGetFlashes()
|
||||||
{
|
{
|
||||||
$helper = new SessionHelper($this->request);
|
$helper = new SessionHelper($this->requestStack);
|
||||||
$this->assertEquals(array('notice' => array('bar')), $helper->getFlashes());
|
$this->assertEquals(array('notice' => array('bar')), $helper->getFlashes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet()
|
public function testGet()
|
||||||
{
|
{
|
||||||
$helper = new SessionHelper($this->request);
|
$helper = new SessionHelper($this->requestStack);
|
||||||
|
|
||||||
$this->assertEquals('bar', $helper->get('foobar'));
|
$this->assertEquals('bar', $helper->get('foobar'));
|
||||||
$this->assertEquals('foo', $helper->get('bar', 'foo'));
|
$this->assertEquals('foo', $helper->get('bar', 'foo'));
|
||||||
@ -63,7 +67,7 @@ class SessionHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGetName()
|
public function testGetName()
|
||||||
{
|
{
|
||||||
$helper = new SessionHelper($this->request);
|
$helper = new SessionHelper($this->requestStack);
|
||||||
|
|
||||||
$this->assertEquals('session', $helper->getName());
|
$this->assertEquals('session', $helper->getName());
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,13 @@ use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
|||||||
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
|
use Symfony\Bundle\TwigBundle\TokenParser\RenderTokenParser;
|
||||||
use Symfony\Bundle\TwigBundle\Node\RenderNode;
|
use Symfony\Bundle\TwigBundle\Node\RenderNode;
|
||||||
|
|
||||||
class RenderTokenParserTest extends TestCase
|
class LegacyRenderTokenParserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getTestsForRender
|
* @dataProvider getTestsForRender
|
||||||
*/
|
*/
|
@ -13,10 +13,12 @@ namespace Symfony\Component\ClassLoader\Tests;
|
|||||||
|
|
||||||
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
|
||||||
|
|
||||||
class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
|
||||||
if (!extension_loaded('apc')) {
|
if (!extension_loaded('apc')) {
|
||||||
$this->markTestSkipped('The apc extension is not available.');
|
$this->markTestSkipped('The apc extension is not available.');
|
||||||
}
|
}
|
@ -13,8 +13,13 @@ namespace Symfony\Component\ClassLoader\Tests;
|
|||||||
|
|
||||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||||
|
|
||||||
class UniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
class LegacyUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getLoadClassTests
|
* @dataProvider getLoadClassTests
|
||||||
*/
|
*/
|
@ -17,8 +17,13 @@ use Symfony\Component\Console\Helper\HelperSet;
|
|||||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||||
use Symfony\Component\Console\Output\StreamOutput;
|
use Symfony\Component\Console\Output\StreamOutput;
|
||||||
|
|
||||||
class DialogHelperTest extends \PHPUnit_Framework_TestCase
|
class LegacyDialogHelperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSelect()
|
public function testSelect()
|
||||||
{
|
{
|
||||||
$dialog = new DialogHelper();
|
$dialog = new DialogHelper();
|
@ -14,8 +14,13 @@ namespace Symfony\Component\Console\Tests\Helper;
|
|||||||
use Symfony\Component\Console\Helper\ProgressHelper;
|
use Symfony\Component\Console\Helper\ProgressHelper;
|
||||||
use Symfony\Component\Console\Output\StreamOutput;
|
use Symfony\Component\Console\Output\StreamOutput;
|
||||||
|
|
||||||
class ProgressHelperTest extends \PHPUnit_Framework_TestCase
|
class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAdvance()
|
public function testAdvance()
|
||||||
{
|
{
|
||||||
$progress = new ProgressHelper();
|
$progress = new ProgressHelper();
|
@ -14,12 +14,13 @@ namespace Symfony\Component\Console\Tests\Helper;
|
|||||||
use Symfony\Component\Console\Helper\TableHelper;
|
use Symfony\Component\Console\Helper\TableHelper;
|
||||||
use Symfony\Component\Console\Output\StreamOutput;
|
use Symfony\Component\Console\Output\StreamOutput;
|
||||||
|
|
||||||
class TableHelperTest extends \PHPUnit_Framework_TestCase
|
class LegacyTableHelperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected $stream;
|
protected $stream;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
$this->stream = fopen('php://memory', 'r+');
|
$this->stream = fopen('php://memory', 'r+');
|
||||||
}
|
}
|
||||||
|
|
@ -39,8 +39,16 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
|
|||||||
$input = new StringInput('--foo=bar');
|
$input = new StringInput('--foo=bar');
|
||||||
$input->bind($definition);
|
$input->bind($definition);
|
||||||
$this->assertEquals('bar', $input->getOption('foo'));
|
$this->assertEquals('bar', $input->getOption('foo'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLegacyInputOptionDefinitionInConstructor()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
$definition = new InputDefinition(
|
||||||
|
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
|
||||||
|
);
|
||||||
|
|
||||||
// definition in constructor
|
|
||||||
$input = new StringInput('--foo=bar', $definition);
|
$input = new StringInput('--foo=bar', $definition);
|
||||||
$this->assertEquals('bar', $input->getOption('foo'));
|
$this->assertEquals('bar', $input->getOption('foo'));
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ if ('cli' !== php_sapi_name()) {
|
|||||||
} elseif (!ini_get('log_errors') || ini_get('error_log')) {
|
} elseif (!ini_get('log_errors') || ini_get('error_log')) {
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
}
|
}
|
||||||
ErrorHandler::register($errorReportingLevel);
|
ErrorHandler::register();
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the `Debug::enable()` call also registers the debug class loader
|
Note that the `Debug::enable()` call also registers the debug class loader
|
||||||
|
@ -21,24 +21,38 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider provideClassNotFoundData
|
* @dataProvider provideClassNotFoundData
|
||||||
*/
|
*/
|
||||||
public function testHandleClassNotFound($error, $translatedMessage, $autoloader = null)
|
public function testHandleClassNotFound($error, $translatedMessage)
|
||||||
{
|
{
|
||||||
if ($autoloader) {
|
$handler = new ClassNotFoundFatalErrorHandler();
|
||||||
// Unregister all autoloaders to ensure the custom provided
|
|
||||||
// autoloader is the only one to be used during the test run.
|
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||||
$autoloaders = spl_autoload_functions();
|
|
||||||
array_map('spl_autoload_unregister', $autoloaders);
|
$this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
||||||
spl_autoload_register($autoloader);
|
$this->assertSame($translatedMessage, $exception->getMessage());
|
||||||
}
|
$this->assertSame($error['type'], $exception->getSeverity());
|
||||||
|
$this->assertSame($error['file'], $exception->getFile());
|
||||||
|
$this->assertSame($error['line'], $exception->getLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideLegacyClassNotFoundData
|
||||||
|
*/
|
||||||
|
public function testLegacyHandleClassNotFound($error, $translatedMessage, $autoloader)
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
// Unregister all autoloaders to ensure the custom provided
|
||||||
|
// autoloader is the only one to be used during the test run.
|
||||||
|
$autoloaders = spl_autoload_functions();
|
||||||
|
array_map('spl_autoload_unregister', $autoloaders);
|
||||||
|
spl_autoload_register($autoloader);
|
||||||
|
|
||||||
$handler = new ClassNotFoundFatalErrorHandler();
|
$handler = new ClassNotFoundFatalErrorHandler();
|
||||||
|
|
||||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||||
|
|
||||||
if ($autoloader) {
|
spl_autoload_unregister($autoloader);
|
||||||
spl_autoload_unregister($autoloader);
|
array_map('spl_autoload_register', $autoloaders);
|
||||||
array_map('spl_autoload_register', $autoloaders);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
$this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception);
|
||||||
$this->assertSame($translatedMessage, $exception->getMessage());
|
$this->assertSame($translatedMessage, $exception->getMessage());
|
||||||
@ -49,14 +63,6 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function provideClassNotFoundData()
|
public function provideClassNotFoundData()
|
||||||
{
|
{
|
||||||
$prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception'));
|
|
||||||
|
|
||||||
$symfonyAutoloader = new SymfonyClassLoader();
|
|
||||||
$symfonyAutoloader->addPrefixes($prefixes);
|
|
||||||
|
|
||||||
$symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
|
|
||||||
$symfonyUniversalClassLoader->registerPrefixes($prefixes);
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
@ -103,6 +109,20 @@ class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
),
|
),
|
||||||
"Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?",
|
"Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\Bar\".\nDid you forget a \"use\" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException\"?",
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideLegacyClassNotFoundData()
|
||||||
|
{
|
||||||
|
$prefixes = array('Symfony\Component\Debug\Exception\\' => realpath(__DIR__.'/../../Exception'));
|
||||||
|
|
||||||
|
$symfonyAutoloader = new SymfonyClassLoader();
|
||||||
|
$symfonyAutoloader->addPrefixes($prefixes);
|
||||||
|
|
||||||
|
$symfonyUniversalClassLoader = new SymfonyUniversalClassLoader();
|
||||||
|
$symfonyUniversalClassLoader->registerPrefixes($prefixes);
|
||||||
|
|
||||||
|
return array(
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
|
@ -74,6 +74,9 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
|||||||
if ($definition->getFactoryService()) {
|
if ($definition->getFactoryService()) {
|
||||||
$this->processArguments(array(new Reference($definition->getFactoryService())));
|
$this->processArguments(array(new Reference($definition->getFactoryService())));
|
||||||
}
|
}
|
||||||
|
if (is_array($definition->getFactory())) {
|
||||||
|
$this->processArguments($definition->getFactory());
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->onlyConstructorArguments) {
|
if (!$this->onlyConstructorArguments) {
|
||||||
$this->processArguments($definition->getMethodCalls());
|
$this->processArguments($definition->getMethodCalls());
|
||||||
@ -81,9 +84,6 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
|||||||
if ($definition->getConfigurator()) {
|
if ($definition->getConfigurator()) {
|
||||||
$this->processArguments(array($definition->getConfigurator()));
|
$this->processArguments(array($definition->getConfigurator()));
|
||||||
}
|
}
|
||||||
if ($definition->getFactory()) {
|
|
||||||
$this->processArguments(array($definition->getFactory()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +115,9 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
|||||||
$this->processArguments($argument->getMethodCalls());
|
$this->processArguments($argument->getMethodCalls());
|
||||||
$this->processArguments($argument->getProperties());
|
$this->processArguments($argument->getProperties());
|
||||||
|
|
||||||
|
if (is_array($argument->getFactory())) {
|
||||||
|
$this->processArguments($argument->getFactory());
|
||||||
|
}
|
||||||
if ($argument->getFactoryService()) {
|
if ($argument->getFactoryService()) {
|
||||||
$this->processArguments(array(new Reference($argument->getFactoryService())));
|
$this->processArguments(array(new Reference($argument->getFactoryService())));
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,10 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($ids) > 1 && is_array($factory = $definition->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (count($ids) > 1 && $definition->getFactoryService()) {
|
if (count($ids) > 1 && $definition->getFactoryService()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -81,11 +81,9 @@ class ResolveDefinitionTemplatesPass implements CompilerPassInterface
|
|||||||
$def->setArguments($parentDef->getArguments());
|
$def->setArguments($parentDef->getArguments());
|
||||||
$def->setMethodCalls($parentDef->getMethodCalls());
|
$def->setMethodCalls($parentDef->getMethodCalls());
|
||||||
$def->setProperties($parentDef->getProperties());
|
$def->setProperties($parentDef->getProperties());
|
||||||
if (null !== $parentDef->getFactoryMethod()) {
|
$def->setFactoryClass($parentDef->getFactoryClass());
|
||||||
$def->setFactoryClass($parentDef->getFactoryClass());
|
$def->setFactoryMethod($parentDef->getFactoryMethod());
|
||||||
$def->setFactoryMethod($parentDef->getFactoryMethod());
|
$def->setFactoryService($parentDef->getFactoryService());
|
||||||
$def->setFactoryService($parentDef->getFactoryService());
|
|
||||||
}
|
|
||||||
$def->setFactory($parentDef->getFactory());
|
$def->setFactory($parentDef->getFactory());
|
||||||
$def->setConfigurator($parentDef->getConfigurator());
|
$def->setConfigurator($parentDef->getConfigurator());
|
||||||
$def->setFile($parentDef->getFile());
|
$def->setFile($parentDef->getFile());
|
||||||
|
@ -87,7 +87,7 @@ class AnalyzeServiceReferencesPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
;
|
;
|
||||||
|
|
||||||
$factory = new Definition();
|
$factory = new Definition();
|
||||||
$factory->setFactoryService('a');
|
$factory->setFactory(array(new Reference('a'), 'a'));
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->register('b')
|
->register('b')
|
||||||
@ -124,13 +124,11 @@ class AnalyzeServiceReferencesPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
->register('foo', 'stdClass')
|
->register('foo', 'stdClass')
|
||||||
->setFactoryClass('stdClass')
|
->setFactory(array('stdClass', 'getInstance'));
|
||||||
->setFactoryMethod('getInstance');
|
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->register('bar', 'stdClass')
|
->register('bar', 'stdClass')
|
||||||
->setFactoryService('foo')
|
->setFactory(array(new Reference('foo'), 'getInstance'));
|
||||||
->setFactoryMethod('getInstance');
|
|
||||||
|
|
||||||
$graph = $this->process($container);
|
$graph = $this->process($container);
|
||||||
|
|
||||||
|
@ -53,13 +53,11 @@ class CheckCircularReferencesPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
->register('a', 'stdClass')
|
->register('a', 'stdClass')
|
||||||
->setFactoryService('b')
|
->setFactory(array(new Reference('b'), 'getInstance'));
|
||||||
->setFactoryMethod('getInstance');
|
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->register('b', 'stdClass')
|
->register('b', 'stdClass')
|
||||||
->setFactoryService('a')
|
->setFactory(array(new Reference('a'), 'getInstance'));
|
||||||
->setFactoryMethod('getInstance');
|
|
||||||
|
|
||||||
$this->process($container);
|
$this->process($container);
|
||||||
}
|
}
|
||||||
@ -88,8 +86,7 @@ class CheckCircularReferencesPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
->register('b', 'stdClass')
|
->register('b', 'stdClass')
|
||||||
->setFactoryService('c')
|
->setFactory(array(new Reference('c'), 'getInstance'));
|
||||||
->setFactoryMethod('getInstance');
|
|
||||||
|
|
||||||
$container->register('c')->addArgument(new Reference('a'));
|
$container->register('c')->addArgument(new Reference('a'));
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$b = $container
|
$b = $container
|
||||||
->register('b')
|
->register('b')
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->setFactoryService('a')
|
->setFactory(array(new Reference('a'), 'a'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$container
|
$container
|
||||||
@ -142,7 +142,7 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$container
|
$container
|
||||||
->register('b')
|
->register('b')
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->setFactoryService('a')
|
->setFactory(array(new Reference('a'), 'a'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$container
|
$container
|
||||||
@ -168,12 +168,12 @@ class InlineServiceDefinitionsPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
$container
|
$container
|
||||||
->register('b')
|
->register('b')
|
||||||
->setPublic(false)
|
->setPublic(false)
|
||||||
->setFactoryService('a')
|
->setFactory(array(new Reference('a'), 'a'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$inlineFactory = new Definition();
|
$inlineFactory = new Definition();
|
||||||
$inlineFactory->setPublic(false);
|
$inlineFactory->setPublic(false);
|
||||||
$inlineFactory->setFactoryService('b');
|
$inlineFactory->setFactory(array(new Reference('b'), 'b'));
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->register('foo')
|
->register('foo')
|
||||||
|
@ -86,14 +86,12 @@ class RemoveUnusedDefinitionsPassTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
->register('foo', 'stdClass')
|
->register('foo', 'stdClass')
|
||||||
->setFactoryClass('stdClass')
|
->setFactory(array('stdClass', 'getInstance'))
|
||||||
->setFactoryMethod('getInstance')
|
|
||||||
->setPublic(false);
|
->setPublic(false);
|
||||||
|
|
||||||
$container
|
$container
|
||||||
->register('bar', 'stdClass')
|
->register('bar', 'stdClass')
|
||||||
->setFactoryService('foo')
|
->setFactory(array(new Reference('foo'), 'getInstance'))
|
||||||
->setFactoryMethod('getInstance')
|
|
||||||
->setPublic(false);
|
->setPublic(false);
|
||||||
|
|
||||||
$container
|
$container
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
|
||||||
$container->setParameter('cla', 'Fo');
|
|
||||||
$container->setParameter('ss', 'Class');
|
|
||||||
|
|
||||||
$definition = new Definition('%cla%o%ss%');
|
|
||||||
$container->setDefinition('foo', $definition);
|
|
||||||
|
|
||||||
return $container;
|
|
||||||
|
|
||||||
if (!class_exists('FooClass')) {
|
|
||||||
class FooClass
|
|
||||||
{
|
|
||||||
public $bar;
|
|
||||||
|
|
||||||
public function setBar($bar)
|
|
||||||
{
|
|
||||||
$this->bar = $bar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
|
||||||
|
|
||||||
$container = new ContainerBuilder();
|
|
||||||
|
|
||||||
$factoryDefinition = new Definition('BarClassFactory');
|
|
||||||
$container->setDefinition('barFactory', $factoryDefinition);
|
|
||||||
|
|
||||||
$definition = new Definition();
|
|
||||||
$definition->setFactoryService('barFactory');
|
|
||||||
$definition->setFactoryMethod('createBarClass');
|
|
||||||
$container->setDefinition('bar', $definition);
|
|
||||||
|
|
||||||
return $container;
|
|
||||||
|
|
||||||
class BarClass
|
|
||||||
{
|
|
||||||
public $foo;
|
|
||||||
|
|
||||||
public function setBar($foo)
|
|
||||||
{
|
|
||||||
$this->foo = $foo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BarClassFactory
|
|
||||||
{
|
|
||||||
public function createBarClass()
|
|
||||||
{
|
|
||||||
return new BarClass();
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,6 +16,11 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||||||
|
|
||||||
class LegacyContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
class LegacyContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
|
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
|
||||||
*/
|
*/
|
||||||
|
@ -60,24 +60,28 @@ class EventTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($this->event->isPropagationStopped());
|
$this->assertTrue($this->event->isPropagationStopped());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDispatcher()
|
public function testLegacySetDispatcher()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
$this->event->setDispatcher($this->dispatcher);
|
$this->event->setDispatcher($this->dispatcher);
|
||||||
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
|
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDispatcher()
|
public function testLegacyGetDispatcher()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
$this->assertNull($this->event->getDispatcher());
|
$this->assertNull($this->event->getDispatcher());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetName()
|
public function testLegacyGetName()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
$this->assertNull($this->event->getName());
|
$this->assertNull($this->event->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetName()
|
public function testLegacySetName()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
$this->event->setName('foo');
|
$this->event->setName('foo');
|
||||||
$this->assertEquals('foo', $this->event->getName());
|
$this->assertEquals('foo', $this->event->getName());
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ class ChoiceType extends AbstractType
|
|||||||
$placeholderView = new ChoiceView(null, '', $options['placeholder']);
|
$placeholderView = new ChoiceView(null, '', $options['placeholder']);
|
||||||
|
|
||||||
// "placeholder" is a reserved index
|
// "placeholder" is a reserved index
|
||||||
// see also ChoiceListInterface::getIndicesForChoices()
|
|
||||||
$this->addSubForms($builder, array('placeholder' => $placeholderView), $options);
|
$this->addSubForms($builder, array('placeholder' => $placeholderView), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ class DateTimeType extends AbstractType
|
|||||||
|
|
||||||
// Don't add some defaults in order to preserve the defaults
|
// Don't add some defaults in order to preserve the defaults
|
||||||
// set in DateType and TimeType
|
// set in DateType and TimeType
|
||||||
$resolver->setOptional(array(
|
$resolver->setDefined(array(
|
||||||
'empty_value', // deprecated
|
'empty_value', // deprecated
|
||||||
'placeholder',
|
'placeholder',
|
||||||
'years',
|
'years',
|
||||||
|
@ -165,7 +165,7 @@ class FormType extends BaseType
|
|||||||
|
|
||||||
// If data is given, the form is locked to that data
|
// If data is given, the form is locked to that data
|
||||||
// (independent of its value)
|
// (independent of its value)
|
||||||
$resolver->setOptional(array(
|
$resolver->setDefined(array(
|
||||||
'data',
|
'data',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -55,39 +55,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
|
|||||||
* ->getFormFactory();
|
* ->getFormFactory();
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* Support for CSRF protection is provided by the CsrfExtension.
|
|
||||||
* This extension needs a CSRF provider with a strong secret
|
|
||||||
* (e.g. a 20 character long random string). The default
|
|
||||||
* implementation for this is DefaultCsrfProvider:
|
|
||||||
*
|
|
||||||
* <code>
|
|
||||||
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
|
||||||
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
|
|
||||||
*
|
|
||||||
* $secret = 'V8a5Z97e...';
|
|
||||||
* $formFactory = Forms::createFormFactoryBuilder()
|
|
||||||
* ->addExtension(new CsrfExtension(new DefaultCsrfProvider($secret)))
|
|
||||||
* ->getFormFactory();
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* Support for the HttpFoundation is provided by the
|
|
||||||
* HttpFoundationExtension. You are also advised to load the CSRF
|
|
||||||
* extension with the driver for HttpFoundation's Session class:
|
|
||||||
*
|
|
||||||
* <code>
|
|
||||||
* use Symfony\Component\HttpFoundation\Session\Session;
|
|
||||||
* use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
|
|
||||||
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
|
||||||
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
|
|
||||||
*
|
|
||||||
* $session = new Session();
|
|
||||||
* $secret = 'V8a5Z97e...';
|
|
||||||
* $formFactory = Forms::createFormFactoryBuilder()
|
|
||||||
* ->addExtension(new HttpFoundationExtension())
|
|
||||||
* ->addExtension(new CsrfExtension(new SessionCsrfProvider($session, $secret)))
|
|
||||||
* ->getFormFactory();
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* Support for the Validator component is provided by ValidatorExtension.
|
* Support for the Validator component is provided by ValidatorExtension.
|
||||||
* This extension needs a validator object to function properly:
|
* This extension needs a validator object to function properly:
|
||||||
*
|
*
|
||||||
@ -129,26 +96,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
|
|||||||
* ->getFormFactory();
|
* ->getFormFactory();
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* If you also loaded the CsrfExtension, you should pass the CSRF provider
|
|
||||||
* to the extension so that you can render CSRF tokens in your templates
|
|
||||||
* more easily:
|
|
||||||
*
|
|
||||||
* <code>
|
|
||||||
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
|
|
||||||
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
|
|
||||||
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $secret = 'V8a5Z97e...';
|
|
||||||
* $csrfProvider = new DefaultCsrfProvider($secret);
|
|
||||||
* $formFactory = Forms::createFormFactoryBuilder()
|
|
||||||
* ->addExtension(new CsrfExtension($csrfProvider))
|
|
||||||
* ->addExtension(new TemplatingExtension($engine, $csrfProvider, array(
|
|
||||||
* 'FrameworkBundle:Form',
|
|
||||||
* )))
|
|
||||||
* ->getFormFactory();
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
final class Forms
|
final class Forms
|
||||||
|
@ -161,63 +161,83 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame($this->values, $this->list->getValues());
|
$this->assertSame($this->values, $this->list->getValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoices()
|
public function testLegacyGetIndicesForChoices()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$choices = array($this->choice1, $this->choice2);
|
$choices = array($this->choice1, $this->choice2);
|
||||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesPreservesKeys()
|
public function testLegacyGetIndicesForChoicesPreservesKeys()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$choices = array(5 => $this->choice1, 8 => $this->choice2);
|
$choices = array(5 => $this->choice1, 8 => $this->choice2);
|
||||||
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesPreservesOrder()
|
public function testLegacyGetIndicesForChoicesPreservesOrder()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$choices = array($this->choice2, $this->choice1);
|
$choices = array($this->choice2, $this->choice1);
|
||||||
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesIgnoresNonExistingChoices()
|
public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$choices = array($this->choice1, $this->choice2, 'foobar');
|
$choices = array($this->choice1, $this->choice2, 'foobar');
|
||||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesEmpty()
|
public function testLegacyGetIndicesForChoicesEmpty()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
|
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValues()
|
public function testLegacyGetIndicesForValues()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
// values and indices are always the same
|
// values and indices are always the same
|
||||||
$values = array($this->value1, $this->value2);
|
$values = array($this->value1, $this->value2);
|
||||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
|
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValuesPreservesKeys()
|
public function testLegacyGetIndicesForValuesPreservesKeys()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
// values and indices are always the same
|
// values and indices are always the same
|
||||||
$values = array(5 => $this->value1, 8 => $this->value2);
|
$values = array(5 => $this->value1, 8 => $this->value2);
|
||||||
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForValues($values));
|
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForValues($values));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValuesPreservesOrder()
|
public function testLegacyGetIndicesForValuesPreservesOrder()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$values = array($this->value2, $this->value1);
|
$values = array($this->value2, $this->value1);
|
||||||
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values));
|
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValuesIgnoresNonExistingValues()
|
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$values = array($this->value1, $this->value2, 'foobar');
|
$values = array($this->value1, $this->value2, 'foobar');
|
||||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
|
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValuesEmpty()
|
public function testLegacyGetIndicesForValuesEmpty()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
|
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,14 +57,18 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
|
$this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoices()
|
public function testLegacyGetIndicesForChoices()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$choices = array('b', 'c');
|
$choices = array('b', 'c');
|
||||||
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValues()
|
public function testLegacyGetIndicesForValues()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$values = array('b', 'c');
|
$values = array('b', 'c');
|
||||||
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
|
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesWithValuePath()
|
public function testLegacyGetIndicesForChoicesWithValuePath()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->list = new ObjectChoiceList(
|
$this->list = new ObjectChoiceList(
|
||||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||||
'name',
|
'name',
|
||||||
@ -200,8 +202,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
|||||||
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesWithValuePathPreservesKeys()
|
public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->list = new ObjectChoiceList(
|
$this->list = new ObjectChoiceList(
|
||||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||||
'name',
|
'name',
|
||||||
@ -214,8 +218,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
|||||||
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesWithValuePathPreservesOrder()
|
public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->list = new ObjectChoiceList(
|
$this->list = new ObjectChoiceList(
|
||||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||||
'name',
|
'name',
|
||||||
@ -228,8 +234,10 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
|
|||||||
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
|
public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->list = new ObjectChoiceList(
|
$this->list = new ObjectChoiceList(
|
||||||
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
|
||||||
'name',
|
'name',
|
||||||
|
@ -15,15 +15,19 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
|
|||||||
|
|
||||||
class SimpleNumericChoiceListTest extends AbstractChoiceListTest
|
class SimpleNumericChoiceListTest extends AbstractChoiceListTest
|
||||||
{
|
{
|
||||||
public function testGetIndicesForChoicesDealsWithNumericChoices()
|
public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
// Pass choices as strings although they are integers
|
// Pass choices as strings although they are integers
|
||||||
$choices = array('0', '1');
|
$choices = array('0', '1');
|
||||||
$this->assertSame(array(0, 1), $this->list->getIndicesForChoices($choices));
|
$this->assertSame(array(0, 1), $this->list->getIndicesForChoices($choices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetIndicesForValuesDealsWithNumericValues()
|
public function testLegacyGetIndicesForValuesDealsWithNumericValues()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
// Pass values as strings although they are integers
|
// Pass values as strings although they are integers
|
||||||
$values = array('0', '1');
|
$values = array('0', '1');
|
||||||
$this->assertSame(array(0, 1), $this->list->getIndicesForValues($values));
|
$this->assertSame(array(0, 1), $this->list->getIndicesForValues($values));
|
||||||
|
@ -13,13 +13,15 @@ namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider;
|
|||||||
|
|
||||||
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
|
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
|
||||||
|
|
||||||
class SessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
|
class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected $provider;
|
protected $provider;
|
||||||
protected $session;
|
protected $session;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->session = $this->getMock(
|
$this->session = $this->getMock(
|
||||||
'Symfony\Component\HttpFoundation\Session\Session',
|
'Symfony\Component\HttpFoundation\Session\Session',
|
||||||
array(),
|
array(),
|
@ -598,7 +598,7 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
private function getMockExecutionContext()
|
private function getMockExecutionContext()
|
||||||
{
|
{
|
||||||
return $this->getMock('Symfony\Component\Validator\ExecutionContextInterface');
|
return $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,16 +122,16 @@ class SimpleFormTest extends AbstractFormTest
|
|||||||
public function testFalseIsConvertedToNull()
|
public function testFalseIsConvertedToNull()
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('\stdClass')
|
$mock = $this->getMockBuilder('\stdClass')
|
||||||
->setMethods(array('preBind'))
|
->setMethods(array('preSubmit'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$mock->expects($this->once())
|
$mock->expects($this->once())
|
||||||
->method('preBind')
|
->method('preSubmit')
|
||||||
->with($this->callback(function ($event) {
|
->with($this->callback(function ($event) {
|
||||||
return null === $event->getData();
|
return null === $event->getData();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$config = new FormConfigBuilder('name', null, $this->dispatcher);
|
$config = new FormConfigBuilder('name', null, $this->dispatcher);
|
||||||
$config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preBind'));
|
$config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit'));
|
||||||
$form = new Form($config);
|
$form = new Form($config);
|
||||||
|
|
||||||
$form->submit(false);
|
$form->submit(false);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"php": ">=5.3.3",
|
"php": ">=5.3.3",
|
||||||
"symfony/event-dispatcher": "~2.1|~3.0.0",
|
"symfony/event-dispatcher": "~2.1|~3.0.0",
|
||||||
"symfony/intl": "~2.3|~3.0.0",
|
"symfony/intl": "~2.3|~3.0.0",
|
||||||
"symfony/options-resolver": "~2.1|~3.0.0",
|
"symfony/options-resolver": "~2.6|~3.0.0",
|
||||||
"symfony/property-access": "~2.3|~3.0.0"
|
"symfony/property-access": "~2.3|~3.0.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
@ -19,6 +19,8 @@ class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
|
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
|
||||||
$this->markTestSkipped('This test requires SQLite support in your environment');
|
$this->markTestSkipped('This test requires SQLite support in your environment');
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
|
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
|
||||||
|
|
||||||
use Symfony\Component\Debug\ErrorHandler;
|
|
||||||
use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
|
use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
|
||||||
|
|
||||||
class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
|
class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Tests\EventListener;
|
namespace Symfony\Component\HttpKernel\Tests\EventListener;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
|
use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
@ -23,11 +24,11 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test to ensure BC without RequestStack
|
* Test to ensure BC without RequestStack
|
||||||
*
|
|
||||||
* @deprecated Deprecated since version 2.4, to be removed in 3.0.
|
|
||||||
*/
|
*/
|
||||||
public function testEventsWithoutRequestStack()
|
public function testLegacyEventsWithoutRequestStack()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
|
||||||
$profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
|
$profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
@ -86,15 +87,16 @@ class ProfilerListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
$requestStack = new RequestStack();
|
||||||
|
$requestStack->push($masterRequest);
|
||||||
|
|
||||||
$onlyException = true;
|
$onlyException = true;
|
||||||
$listener = new ProfilerListener($profiler, null, $onlyException);
|
$listener = new ProfilerListener($profiler, null, $onlyException, false, $requestStack);
|
||||||
|
|
||||||
// master request
|
// master request
|
||||||
$listener->onKernelRequest(new GetResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST));
|
|
||||||
$listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response));
|
$listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response));
|
||||||
|
|
||||||
// sub request
|
// sub request
|
||||||
$listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST));
|
|
||||||
$listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404)));
|
$listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404)));
|
||||||
$listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response));
|
$listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response));
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class EsiListenerTest extends \PHPUnit_Framework_TestCase
|
class SurrogateListenerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testFilterDoesNothingForSubRequests()
|
public function testFilterDoesNothingForSubRequests()
|
||||||
{
|
{
|
@ -274,21 +274,21 @@ EOF;
|
|||||||
$this->assertEquals($expected, $output);
|
$this->assertEquals($expected, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsClassInActiveBundleFalse()
|
public function testLegacyIsClassInActiveBundleFalse()
|
||||||
{
|
{
|
||||||
$kernel = $this->getKernelMockForIsClassInActiveBundleTest();
|
$kernel = $this->getKernelMockForIsClassInActiveBundleTest();
|
||||||
|
|
||||||
$this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle'));
|
$this->assertFalse($kernel->isClassInActiveBundle('Not\In\Active\Bundle'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsClassInActiveBundleFalseNoNamespace()
|
public function testLegacyIsClassInActiveBundleFalseNoNamespace()
|
||||||
{
|
{
|
||||||
$kernel = $this->getKernelMockForIsClassInActiveBundleTest();
|
$kernel = $this->getKernelMockForIsClassInActiveBundleTest();
|
||||||
|
|
||||||
$this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass'));
|
$this->assertFalse($kernel->isClassInActiveBundle('NotNamespacedClass'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsClassInActiveBundleTrue()
|
public function testLegacyIsClassInActiveBundleTrue()
|
||||||
{
|
{
|
||||||
$kernel = $this->getKernelMockForIsClassInActiveBundleTest();
|
$kernel = $this->getKernelMockForIsClassInActiveBundleTest();
|
||||||
|
|
||||||
@ -297,6 +297,8 @@ EOF;
|
|||||||
|
|
||||||
protected function getKernelMockForIsClassInActiveBundleTest()
|
protected function getKernelMockForIsClassInActiveBundleTest()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
|
||||||
$bundle = new FooBarBundle();
|
$bundle = new FooBarBundle();
|
||||||
|
|
||||||
$kernel = $this->getKernel(array('getBundles'));
|
$kernel = $this->getKernel(array('getBundles'));
|
||||||
|
@ -14,10 +14,7 @@ namespace Symfony\Component\OptionsResolver\Tests;
|
|||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
|
||||||
/**
|
class LegacyOptionsResolverTest extends \PHPUnit_Framework_TestCase
|
||||||
* @deprecated Deprecated since Symfony 2.6, to be removed in Symfony 3.0.
|
|
||||||
*/
|
|
||||||
class OptionsResolverTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var OptionsResolver
|
* @var OptionsResolver
|
||||||
@ -26,6 +23,8 @@ class OptionsResolverTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->resolver = new OptionsResolver();
|
$this->resolver = new OptionsResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,4 +716,16 @@ class OptionsResolverTest extends \PHPUnit_Framework_TestCase
|
|||||||
'three' => '3',
|
'three' => '3',
|
||||||
), $clone->resolve());
|
), $clone->resolve());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testOverloadReturnsThis()
|
||||||
|
{
|
||||||
|
$this->assertSame($this->resolver, $this->resolver->overload('foo', 'bar'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testOverloadCallsSet()
|
||||||
|
{
|
||||||
|
$this->resolver->overload('foo', 'bar');
|
||||||
|
|
||||||
|
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,10 +14,7 @@ namespace Symfony\Component\OptionsResolver\Tests;
|
|||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/**
|
class LegacyOptionsTest extends \PHPUnit_Framework_TestCase
|
||||||
* @deprecated Deprecated since Symfony 2.6, to be removed in Symfony 3.0.
|
|
||||||
*/
|
|
||||||
class OptionsTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var OptionsResolver
|
* @var OptionsResolver
|
||||||
@ -26,6 +23,8 @@ class OptionsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->options = new OptionsResolver();
|
$this->options = new OptionsResolver();
|
||||||
}
|
}
|
||||||
|
|
@ -113,22 +113,6 @@ class OptionsResolver2Dot6Test extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($this->resolver->hasDefault('foo'));
|
$this->assertTrue($this->resolver->hasDefault('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// overload()
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public function testOverloadReturnsThis()
|
|
||||||
{
|
|
||||||
$this->assertSame($this->resolver, $this->resolver->overload('foo', 'bar'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testOverloadCallsSet()
|
|
||||||
{
|
|
||||||
$this->resolver->overload('foo', 'bar');
|
|
||||||
|
|
||||||
$this->assertSame(array('foo' => 'bar'), $this->resolver->resolve());
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// lazy setDefault()
|
// lazy setDefault()
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Routing\Route;
|
|||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
|
use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
|
||||||
|
|
||||||
class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
class LegacyApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected static $fixturesPath;
|
protected static $fixturesPath;
|
||||||
|
|
||||||
@ -24,6 +24,11 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/');
|
self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
public function testDump()
|
public function testDump()
|
||||||
{
|
{
|
||||||
$dumper = new ApacheMatcherDumper($this->getRouteCollection());
|
$dumper = new ApacheMatcherDumper($this->getRouteCollection());
|
@ -15,12 +15,13 @@ use Symfony\Component\Routing\RouteCollection;
|
|||||||
use Symfony\Component\Routing\RequestContext;
|
use Symfony\Component\Routing\RequestContext;
|
||||||
use Symfony\Component\Routing\Matcher\ApacheUrlMatcher;
|
use Symfony\Component\Routing\Matcher\ApacheUrlMatcher;
|
||||||
|
|
||||||
class ApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
|
class LegacyApacheUrlMatcherTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected $server;
|
protected $server;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||||
$this->server = $_SERVER;
|
$this->server = $_SERVER;
|
||||||
}
|
}
|
||||||
|
|
@ -70,8 +70,6 @@ class SecurityContext implements SecurityContextInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0. Use TokenStorageInterface::getToken() instead.
|
|
||||||
*
|
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getToken()
|
public function getToken()
|
||||||
@ -80,8 +78,6 @@ class SecurityContext implements SecurityContextInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0. Use TokenStorageInterface::setToken() instead.
|
|
||||||
*
|
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setToken(TokenInterface $token = null)
|
public function setToken(TokenInterface $token = null)
|
||||||
@ -90,8 +86,6 @@ class SecurityContext implements SecurityContextInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Deprecated since version 2.6, to be removed in 3.0. Use AuthorizationCheckerInterface::isGranted() instead.
|
|
||||||
*
|
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function isGranted($attributes, $object = null)
|
public function isGranted($attributes, $object = null)
|
||||||
|
@ -86,7 +86,8 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate('secret', $constraint);
|
$this->validator->validate('secret', $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage');
|
$this->buildViolation('myMessage')
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,15 +14,15 @@ namespace Symfony\Component\Security\Tests\Core;
|
|||||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
class SecurityContextInterfaceTest extends \PHPUnit_Framework_TestCase
|
class LegacySecurityContextInterfaceTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test if the BC Layer is working as intended
|
* Test if the BC Layer is working as intended
|
||||||
*
|
|
||||||
* @deprecated since version 2.6, to be removed in 3.0.
|
|
||||||
*/
|
*/
|
||||||
public function testConstantSync()
|
public function testConstantSync()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->assertSame(Security::ACCESS_DENIED_ERROR, SecurityContextInterface::ACCESS_DENIED_ERROR);
|
$this->assertSame(Security::ACCESS_DENIED_ERROR, SecurityContextInterface::ACCESS_DENIED_ERROR);
|
||||||
$this->assertSame(Security::AUTHENTICATION_ERROR, SecurityContextInterface::AUTHENTICATION_ERROR);
|
$this->assertSame(Security::AUTHENTICATION_ERROR, SecurityContextInterface::AUTHENTICATION_ERROR);
|
||||||
$this->assertSame(Security::LAST_USERNAME, SecurityContextInterface::LAST_USERNAME);
|
$this->assertSame(Security::LAST_USERNAME, SecurityContextInterface::LAST_USERNAME);
|
@ -24,8 +24,10 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance');
|
$this->assertSame($logger, $loader->getLogger(), '->setLogger() sets the logger instance');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSetDebugger()
|
public function testLegacyGetSetDebugger()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$loader = new ProjectTemplateLoader4();
|
$loader = new ProjectTemplateLoader4();
|
||||||
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
|
$debugger = $this->getMock('Symfony\Component\Templating\DebuggerInterface');
|
||||||
$loader->setDebugger($debugger);
|
$loader->setDebugger($debugger);
|
||||||
|
@ -55,6 +55,8 @@ use Symfony\Component\Validator\Exception\OutOfBoundsException;
|
|||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
*
|
||||||
|
* Implementing \ArrayAccess, \IteratorAggregate and \Countable is @deprecated since 2.5 and will be removed in 3.0.
|
||||||
*/
|
*/
|
||||||
class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
|
class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,10 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
if (Validation::API_VERSION_2_5 !== $this->getApiVersion()) {
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
$this->group = 'MyGroup';
|
$this->group = 'MyGroup';
|
||||||
$this->metadata = null;
|
$this->metadata = null;
|
||||||
$this->object = null;
|
$this->object = null;
|
||||||
|
@ -20,7 +20,7 @@ use Symfony\Component\Validator\ExecutionContext;
|
|||||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||||
use Symfony\Component\Validator\ValidationVisitor;
|
use Symfony\Component\Validator\ValidationVisitor;
|
||||||
|
|
||||||
class ExecutionContextTest extends \PHPUnit_Framework_TestCase
|
class LegacyExecutionContextTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
const TRANS_DOMAIN = 'trans_domain';
|
const TRANS_DOMAIN = 'trans_domain';
|
||||||
|
|
||||||
@ -38,6 +38,8 @@ class ExecutionContextTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->visitor = $this->getMockBuilder('Symfony\Component\Validator\ValidationVisitor')
|
$this->visitor = $this->getMockBuilder('Symfony\Component\Validator\ValidationVisitor')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
@ -13,10 +13,12 @@ namespace Symfony\Component\Validator\Tests\Mapping\Cache;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Mapping\Cache\ApcCache;
|
use Symfony\Component\Validator\Mapping\Cache\ApcCache;
|
||||||
|
|
||||||
class ApcCacheTest extends \PHPUnit_Framework_TestCase
|
class LegacyApcCacheTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) {
|
if (!extension_loaded('apc') || !ini_get('apc.enable_cli')) {
|
||||||
$this->markTestSkipped('APC is not loaded.');
|
$this->markTestSkipped('APC is not loaded.');
|
||||||
}
|
}
|
@ -270,14 +270,6 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($metadata->isGroupSequenceProvider());
|
$this->assertTrue($metadata->isGroupSequenceProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* https://github.com/symfony/symfony/issues/11604.
|
|
||||||
*/
|
|
||||||
public function testGetMemberMetadatasReturnsEmptyArrayWithoutConfiguredMetadata()
|
|
||||||
{
|
|
||||||
$this->assertCount(0, $this->metadata->getMemberMetadatas('foo'), '->getMemberMetadatas() returns an empty collection if no metadata is configured for the given property');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/symfony/symfony/issues/11604.
|
* https://github.com/symfony/symfony/issues/11604.
|
||||||
*/
|
*/
|
||||||
|
@ -9,24 +9,24 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Mapping;
|
namespace Symfony\Component\Validator\Tests\Mapping\Factory;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Mapping\BlackholeMetadataFactory;
|
use Symfony\Component\Validator\Mapping\Factory\BlackHoleMetadataFactory;
|
||||||
|
|
||||||
class BlackholeMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
class BlackHoleMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \LogicException
|
* @expectedException \LogicException
|
||||||
*/
|
*/
|
||||||
public function testGetMetadataForThrowsALogicException()
|
public function testGetMetadataForThrowsALogicException()
|
||||||
{
|
{
|
||||||
$metadataFactory = new BlackholeMetadataFactory();
|
$metadataFactory = new BlackHoleMetadataFactory();
|
||||||
$metadataFactory->getMetadataFor('foo');
|
$metadataFactory->getMetadataFor('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHasMetadataForReturnsFalse()
|
public function testHasMetadataForReturnsFalse()
|
||||||
{
|
{
|
||||||
$metadataFactory = new BlackholeMetadataFactory();
|
$metadataFactory = new BlackHoleMetadataFactory();
|
||||||
|
|
||||||
$this->assertFalse($metadataFactory->hasMetadataFor('foo'));
|
$this->assertFalse($metadataFactory->hasMetadataFor('foo'));
|
||||||
}
|
}
|
@ -9,21 +9,21 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Mapping;
|
namespace Symfony\Component\Validator\Tests\Mapping\Factory;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
|
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
|
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||||
|
|
||||||
class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
|
||||||
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
|
||||||
|
|
||||||
public function testLoadClassMetadata()
|
public function testLoadClassMetadata()
|
||||||
{
|
{
|
||||||
$factory = new ClassMetadataFactory(new TestLoader());
|
$factory = new LazyLoadingMetadataFactory(new TestLoader());
|
||||||
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
|
$metadata = $factory->getMetadataFor(self::PARENTCLASS);
|
||||||
|
|
||||||
$constraints = array(
|
$constraints = array(
|
||||||
@ -35,7 +35,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testMergeParentConstraints()
|
public function testMergeParentConstraints()
|
||||||
{
|
{
|
||||||
$factory = new ClassMetadataFactory(new TestLoader());
|
$factory = new LazyLoadingMetadataFactory(new TestLoader());
|
||||||
$metadata = $factory->getMetadataFor(self::CLASSNAME);
|
$metadata = $factory->getMetadataFor(self::CLASSNAME);
|
||||||
|
|
||||||
$constraints = array(
|
$constraints = array(
|
||||||
@ -61,7 +61,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testWriteMetadataToCache()
|
public function testWriteMetadataToCache()
|
||||||
{
|
{
|
||||||
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
|
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
|
||||||
$factory = new ClassMetadataFactory(new TestLoader(), $cache);
|
$factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache);
|
||||||
|
|
||||||
$tester = $this;
|
$tester = $this;
|
||||||
$constraints = array(
|
$constraints = array(
|
||||||
@ -90,7 +90,7 @@ class ClassMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$loader = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
|
$loader = $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
|
||||||
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
|
$cache = $this->getMock('Symfony\Component\Validator\Mapping\Cache\CacheInterface');
|
||||||
$factory = new ClassMetadataFactory($loader, $cache);
|
$factory = new LazyLoadingMetadataFactory($loader, $cache);
|
||||||
|
|
||||||
$tester = $this;
|
$tester = $this;
|
||||||
$metadata = new ClassMetadata(self::PARENTCLASS);
|
$metadata = new ClassMetadata(self::PARENTCLASS);
|
@ -15,12 +15,14 @@ use Symfony\Component\Validator\Mapping\ElementMetadata;
|
|||||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
use Symfony\Component\Validator\Tests\Fixtures\ConstraintB;
|
||||||
|
|
||||||
class ElementMetadataTest extends \PHPUnit_Framework_TestCase
|
class LegacyElementMetadataTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
protected $metadata;
|
protected $metadata;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->metadata = new TestElementMetadata();
|
$this->metadata = new TestElementMetadata();
|
||||||
}
|
}
|
||||||
|
|
@ -634,8 +634,10 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
|
|||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
|
* @expectedException \Symfony\Component\Validator\Exception\UnsupportedMetadataException
|
||||||
*/
|
*/
|
||||||
public function testPropertyMetadataMustImplementPropertyMetadataInterface()
|
public function testLegacyPropertyMetadataMustImplementPropertyMetadataInterface()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$entity = new Entity();
|
$entity = new Entity();
|
||||||
|
|
||||||
// Legacy interface
|
// Legacy interface
|
||||||
|
@ -42,6 +42,8 @@ abstract class AbstractLegacyApiTest extends AbstractValidatorTest
|
|||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->validator = $this->createValidator($this->metadataFactory);
|
$this->validator = $this->createValidator($this->metadataFactory);
|
||||||
|
@ -841,8 +841,10 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
|
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
|
||||||
*/
|
*/
|
||||||
public function testValidatePropertyFailsIfPropertiesNotSupported()
|
public function testLegacyValidatePropertyFailsIfPropertiesNotSupported()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
// $metadata does not implement PropertyMetadataContainerInterface
|
// $metadata does not implement PropertyMetadataContainerInterface
|
||||||
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
|
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
|
||||||
|
|
||||||
@ -971,8 +973,10 @@ abstract class AbstractValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
|
* @expectedException \Symfony\Component\Validator\Exception\ValidatorException
|
||||||
*/
|
*/
|
||||||
public function testValidatePropertyValueFailsIfPropertiesNotSupported()
|
public function testLegacyValidatePropertyValueFailsIfPropertiesNotSupported()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
// $metadata does not implement PropertyMetadataContainerInterface
|
// $metadata does not implement PropertyMetadataContainerInterface
|
||||||
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
|
$metadata = $this->getMock('Symfony\Component\Validator\MetadataInterface');
|
||||||
|
|
||||||
|
@ -110,8 +110,10 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN'));
|
$this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultApiVersion()
|
public function testLegacyDefaultApiVersion()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50309) {
|
if (PHP_VERSION_ID < 50309) {
|
||||||
// Old implementation on PHP < 5.3.9
|
// Old implementation on PHP < 5.3.9
|
||||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
|
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
|
||||||
@ -121,8 +123,10 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetApiVersion24()
|
public function testLegacySetApiVersion24()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
$this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_4));
|
$this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_4));
|
||||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
|
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
|
||||||
}
|
}
|
||||||
@ -133,8 +137,10 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator());
|
$this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetApiVersion24And25()
|
public function testLegacySetApiVersion24And25()
|
||||||
{
|
{
|
||||||
|
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50309) {
|
if (PHP_VERSION_ID < 50309) {
|
||||||
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ use Symfony\Component\Validator\Exception\InvalidArgumentException;
|
|||||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||||
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
|
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
|
use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
|
||||||
|
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
|
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\LoaderChain;
|
use Symfony\Component\Validator\Mapping\Loader\LoaderChain;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
|
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
|
||||||
@ -349,6 +350,13 @@ class ValidatorBuilder implements ValidatorBuilderInterface
|
|||||||
public function getValidator()
|
public function getValidator()
|
||||||
{
|
{
|
||||||
$metadataFactory = $this->metadataFactory;
|
$metadataFactory = $this->metadataFactory;
|
||||||
|
$apiVersion = $this->apiVersion;
|
||||||
|
|
||||||
|
if (null === $apiVersion) {
|
||||||
|
$apiVersion = PHP_VERSION_ID < 50309
|
||||||
|
? Validation::API_VERSION_2_4
|
||||||
|
: Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$metadataFactory) {
|
if (!$metadataFactory) {
|
||||||
$loaders = array();
|
$loaders = array();
|
||||||
@ -381,18 +389,15 @@ class ValidatorBuilder implements ValidatorBuilderInterface
|
|||||||
$loader = $loaders[0];
|
$loader = $loaders[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadataFactory = new ClassMetadataFactory($loader, $this->metadataCache);
|
if (Validation::API_VERSION_2_5 === $apiVersion) {
|
||||||
|
$metadataFactory = new LazyLoadingMetadataFactory($loader, $this->metadataCache);
|
||||||
|
} else {
|
||||||
|
$metadataFactory = new ClassMetadataFactory($loader, $this->metadataCache);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($this->propertyAccessor);
|
$validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($this->propertyAccessor);
|
||||||
$translator = $this->translator ?: new DefaultTranslator();
|
$translator = $this->translator ?: new DefaultTranslator();
|
||||||
$apiVersion = $this->apiVersion;
|
|
||||||
|
|
||||||
if (null === $apiVersion) {
|
|
||||||
$apiVersion = PHP_VERSION_ID < 50309
|
|
||||||
? Validation::API_VERSION_2_4
|
|
||||||
: Validation::API_VERSION_2_5_BC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Validation::API_VERSION_2_4 === $apiVersion) {
|
if (Validation::API_VERSION_2_4 === $apiVersion) {
|
||||||
return new ValidatorV24($metadataFactory, $validatorFactory, $translator, $this->translationDomain, $this->initializers);
|
return new ValidatorV24($metadataFactory, $validatorFactory, $translator, $this->translationDomain, $this->initializers);
|
||||||
|
Reference in New Issue
Block a user