minor #14222 [Form] Fix declaration of legacy tests (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[Form] Fix declaration of legacy tests

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

4a74aba [Form] Fix declaration of legacy tests
This commit is contained in:
Nicolas Grekas 2015-04-05 19:45:50 +02:00
commit 69eae1d206
12 changed files with 71 additions and 147 deletions

View File

@ -131,10 +131,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
/** /**
* @group legacy * @group legacy
*/ */
public function testLegacyEnctype() public function testEnctype()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$form = $this->factory->createNamedBuilder('name', 'form') $form = $this->factory->createNamedBuilder('name', 'form')
->add('file', 'file') ->add('file', 'file')
->getForm(); ->getForm();
@ -145,10 +143,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
/** /**
* @group legacy * @group legacy
*/ */
public function testLegacyNoEnctype() public function testNoEnctype()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$form = $this->factory->createNamedBuilder('name', 'form') $form = $this->factory->createNamedBuilder('name', 'form')
->add('text', 'text') ->add('text', 'text')
->getForm(); ->getForm();

View File

@ -810,10 +810,8 @@ class CompoundFormTest extends AbstractFormTest
/** /**
* @group legacy * @group legacy
*/ */
public function testLegacyGetErrorsAsStringDeep() public function testGetErrorsAsStringDeep()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$parent = $this->getBuilder() $parent = $this->getBuilder()
->setCompound(true) ->setCompound(true)
->setDataMapper($this->getDataMapper()) ->setDataMapper($this->getDataMapper())
@ -834,10 +832,8 @@ class CompoundFormTest extends AbstractFormTest
/** /**
* @group legacy * @group legacy
*/ */
public function testLegacyGetErrorsAsStringDeepWithIndentation() public function testGetErrorsAsStringDeepWithIndentation()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$parent = $this->getBuilder() $parent = $this->getBuilder()
->setCompound(true) ->setCompound(true)
->setDataMapper($this->getDataMapper()) ->setDataMapper($this->getDataMapper())

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
/** /**
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
*
* @group legacy
*/ */
abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
{ {
@ -123,8 +125,6 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
parent::setUp(); parent::setUp();
$this->list = $this->createChoiceList(); $this->list = $this->createChoiceList();
@ -153,151 +153,131 @@ abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase
} }
} }
public function testLegacyGetChoices() public function testGetChoices()
{ {
$this->assertSame($this->choices, $this->list->getChoices()); $this->assertSame($this->choices, $this->list->getChoices());
} }
public function testLegacyGetValues() public function testGetValues()
{ {
$this->assertSame($this->values, $this->list->getValues()); $this->assertSame($this->values, $this->list->getValues());
} }
public function testLegacyGetIndicesForChoices() public function testGetIndicesForChoices()
{ {
$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 testLegacyGetIndicesForChoicesPreservesKeys() public function testGetIndicesForChoicesPreservesKeys()
{ {
$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 testLegacyGetIndicesForChoicesPreservesOrder() public function testGetIndicesForChoicesPreservesOrder()
{ {
$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 testLegacyGetIndicesForChoicesIgnoresNonExistingChoices() public function testGetIndicesForChoicesIgnoresNonExistingChoices()
{ {
$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 testLegacyGetIndicesForChoicesEmpty() public function testGetIndicesForChoicesEmpty()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertSame(array(), $this->list->getIndicesForChoices(array())); $this->assertSame(array(), $this->list->getIndicesForChoices(array()));
} }
public function testLegacyGetIndicesForValues() public function testGetIndicesForValues()
{ {
$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 testLegacyGetIndicesForValuesPreservesKeys() public function testGetIndicesForValuesPreservesKeys()
{ {
$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 testLegacyGetIndicesForValuesPreservesOrder() public function testGetIndicesForValuesPreservesOrder()
{ {
$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 testLegacyGetIndicesForValuesIgnoresNonExistingValues() public function testGetIndicesForValuesIgnoresNonExistingValues()
{ {
$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 testLegacyGetIndicesForValuesEmpty() public function testGetIndicesForValuesEmpty()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->assertSame(array(), $this->list->getIndicesForValues(array())); $this->assertSame(array(), $this->list->getIndicesForValues(array()));
} }
public function testLegacyGetChoicesForValues() public function testGetChoicesForValues()
{ {
$values = array($this->value1, $this->value2); $values = array($this->value1, $this->value2);
$this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values)); $this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values));
} }
public function testLegacyGetChoicesForValuesPreservesKeys() public function testGetChoicesForValuesPreservesKeys()
{ {
$values = array(5 => $this->value1, 8 => $this->value2); $values = array(5 => $this->value1, 8 => $this->value2);
$this->assertSame(array(5 => $this->choice1, 8 => $this->choice2), $this->list->getChoicesForValues($values)); $this->assertSame(array(5 => $this->choice1, 8 => $this->choice2), $this->list->getChoicesForValues($values));
} }
public function testLegacyGetChoicesForValuesPreservesOrder() public function testGetChoicesForValuesPreservesOrder()
{ {
$values = array($this->value2, $this->value1); $values = array($this->value2, $this->value1);
$this->assertSame(array($this->choice2, $this->choice1), $this->list->getChoicesForValues($values)); $this->assertSame(array($this->choice2, $this->choice1), $this->list->getChoicesForValues($values));
} }
public function testLegacyGetChoicesForValuesIgnoresNonExistingValues() public function testGetChoicesForValuesIgnoresNonExistingValues()
{ {
$values = array($this->value1, $this->value2, 'foobar'); $values = array($this->value1, $this->value2, 'foobar');
$this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values)); $this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values));
} }
// https://github.com/symfony/symfony/issues/3446 // https://github.com/symfony/symfony/issues/3446
public function testLegacyGetChoicesForValuesEmpty() public function testGetChoicesForValuesEmpty()
{ {
$this->assertSame(array(), $this->list->getChoicesForValues(array())); $this->assertSame(array(), $this->list->getChoicesForValues(array()));
} }
public function testLegacyGetValuesForChoices() public function testGetValuesForChoices()
{ {
$choices = array($this->choice1, $this->choice2); $choices = array($this->choice1, $this->choice2);
$this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices)); $this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesPreservesKeys() public function testGetValuesForChoicesPreservesKeys()
{ {
$choices = array(5 => $this->choice1, 8 => $this->choice2); $choices = array(5 => $this->choice1, 8 => $this->choice2);
$this->assertSame(array(5 => $this->value1, 8 => $this->value2), $this->list->getValuesForChoices($choices)); $this->assertSame(array(5 => $this->value1, 8 => $this->value2), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesPreservesOrder() public function testGetValuesForChoicesPreservesOrder()
{ {
$choices = array($this->choice2, $this->choice1); $choices = array($this->choice2, $this->choice1);
$this->assertSame(array($this->value2, $this->value1), $this->list->getValuesForChoices($choices)); $this->assertSame(array($this->value2, $this->value1), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesIgnoresNonExistingChoices() public function testGetValuesForChoicesIgnoresNonExistingChoices()
{ {
$choices = array($this->choice1, $this->choice2, 'foobar'); $choices = array($this->choice1, $this->choice2, 'foobar');
$this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices)); $this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesEmpty() public function testGetValuesForChoicesEmpty()
{ {
$this->assertSame(array(), $this->list->getValuesForChoices(array())); $this->assertSame(array(), $this->list->getValuesForChoices(array()));
} }

View File

@ -37,7 +37,7 @@ class ChoiceListTest extends AbstractChoiceListTest
parent::setUp(); parent::setUp();
} }
public function testLegacyInitArray() public function testInitArray()
{ {
$this->list = new ChoiceList( $this->list = new ChoiceList(
array($this->obj1, $this->obj2, $this->obj3, $this->obj4), array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@ -56,7 +56,7 @@ class ChoiceListTest extends AbstractChoiceListTest
* choices parameter. A choice itself that is an object implementing \Traversable * choices parameter. A choice itself that is an object implementing \Traversable
* is not treated as hierarchical structure, but as-is. * is not treated as hierarchical structure, but as-is.
*/ */
public function testLegacyInitNestedTraversable() public function testInitNestedTraversable()
{ {
$traversableChoice = new \ArrayIterator(array($this->obj3, $this->obj4)); $traversableChoice = new \ArrayIterator(array($this->obj3, $this->obj4));
@ -83,7 +83,7 @@ class ChoiceListTest extends AbstractChoiceListTest
), $this->list->getRemainingViews()); ), $this->list->getRemainingViews());
} }
public function testLegacyInitNestedArray() public function testInitNestedArray()
{ {
$this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
$this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
@ -100,7 +100,7 @@ class ChoiceListTest extends AbstractChoiceListTest
/** /**
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException
*/ */
public function testLegacyInitWithInsufficientLabels() public function testInitWithInsufficientLabels()
{ {
$this->list = new ChoiceList( $this->list = new ChoiceList(
array($this->obj1, $this->obj2), array($this->obj1, $this->obj2),
@ -108,7 +108,7 @@ class ChoiceListTest extends AbstractChoiceListTest
); );
} }
public function testLegacyInitWithLabelsContainingNull() public function testInitWithLabelsContainingNull()
{ {
$this->list = new ChoiceList( $this->list = new ChoiceList(
array($this->obj1, $this->obj2), array($this->obj1, $this->obj2),

View File

@ -43,55 +43,45 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
$this->list = null; $this->list = null;
} }
public function testLegacyGetChoices() public function testGetChoices()
{ {
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices()); $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices());
} }
public function testLegacyGetValues() public function testGetValues()
{ {
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues()); $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues());
} }
public function testLegacyGetPreferredViews() public function testGetPreferredViews()
{ {
$this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews()); $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews());
} }
public function testLegacyGetRemainingViews() public function testGetRemainingViews()
{ {
$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()
* @group legacy
*/
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()
* @group legacy
*/
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));
} }
public function testLegacyGetChoicesForValues() public function testGetChoicesForValues()
{ {
$values = array('b', 'c'); $values = array('b', 'c');
$this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values)); $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values));
} }
public function testLegacyGetValuesForChoices() public function testGetValuesForChoices()
{ {
$choices = array('b', 'c'); $choices = array('b', 'c');
$this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices)); $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices));
@ -100,7 +90,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
/** /**
* @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
*/ */
public function testLegacyLoadChoiceListShouldReturnChoiceList() public function testLoadChoiceListShouldReturnChoiceList()
{ {
$list = new LazyChoiceListTest_InvalidImpl(); $list = new LazyChoiceListTest_InvalidImpl();

View File

@ -52,7 +52,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
parent::setUp(); parent::setUp();
} }
public function testLegacyInitArray() public function testInitArray()
{ {
$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),
@ -66,7 +66,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews());
} }
public function testLegacyInitNestedArray() public function testInitNestedArray()
{ {
$this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
$this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
@ -80,7 +80,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
), $this->list->getRemainingViews()); ), $this->list->getRemainingViews());
} }
public function testLegacyInitArrayWithGroupPath() public function testInitArrayWithGroupPath()
{ {
$this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1'); $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1');
$this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1'); $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1');
@ -118,7 +118,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
/** /**
* @expectedException \InvalidArgumentException * @expectedException \InvalidArgumentException
*/ */
public function testLegacyInitArrayWithGroupPathThrowsExceptionIfNestedArray() public function testInitArrayWithGroupPathThrowsExceptionIfNestedArray()
{ {
$this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1'); $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1');
$this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1'); $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1');
@ -136,7 +136,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
); );
} }
public function testLegacyInitArrayWithValuePath() public function testInitArrayWithValuePath()
{ {
$this->obj1 = (object) array('name' => 'A', 'id' => 10); $this->obj1 = (object) array('name' => 'A', 'id' => 10);
$this->obj2 = (object) array('name' => 'B', 'id' => 20); $this->obj2 = (object) array('name' => 'B', 'id' => 20);
@ -157,7 +157,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews()); $this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews());
} }
public function testLegacyInitArrayUsesToString() public function testInitArrayUsesToString()
{ {
$this->obj1 = new ObjectChoiceListTest_EntityWithToString('A'); $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A');
$this->obj2 = new ObjectChoiceListTest_EntityWithToString('B'); $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B');
@ -176,7 +176,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
/** /**
* @expectedException \Symfony\Component\Form\Exception\StringCastException * @expectedException \Symfony\Component\Form\Exception\StringCastException
*/ */
public function testLegacyInitArrayThrowsExceptionIfToStringNotFound() public function testInitArrayThrowsExceptionIfToStringNotFound()
{ {
$this->obj1 = new ObjectChoiceListTest_EntityWithToString('A'); $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A');
$this->obj2 = new ObjectChoiceListTest_EntityWithToString('B'); $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B');
@ -188,13 +188,8 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
); );
} }
/** public function testGetIndicesForChoicesWithValuePath()
* @group legacy
*/
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',
@ -208,13 +203,8 @@ 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()
* @group legacy
*/
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',
@ -227,13 +217,8 @@ 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()
* @group legacy
*/
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',
@ -246,13 +231,8 @@ 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()
* @group legacy
*/
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',
@ -265,7 +245,7 @@ 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 testLegacyGetValuesForChoicesWithValuePath() public function testGetValuesForChoicesWithValuePath()
{ {
$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),
@ -279,7 +259,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertSame(array('A', 'B'), $this->list->getValuesForChoices($choices)); $this->assertSame(array('A', 'B'), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesWithValuePathPreservesKeys() public function testGetValuesForChoicesWithValuePathPreservesKeys()
{ {
$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),
@ -293,7 +273,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertSame(array(5 => 'A', 8 => 'B'), $this->list->getValuesForChoices($choices)); $this->assertSame(array(5 => 'A', 8 => 'B'), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesWithValuePathPreservesOrder() public function testGetValuesForChoicesWithValuePathPreservesOrder()
{ {
$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),
@ -307,7 +287,7 @@ class ObjectChoiceListTest extends AbstractChoiceListTest
$this->assertSame(array('B', 'A'), $this->list->getValuesForChoices($choices)); $this->assertSame(array('B', 'A'), $this->list->getValuesForChoices($choices));
} }
public function testLegacyGetValuesForChoicesWithValuePathIgnoresNonExistingChoices() public function testGetValuesForChoicesWithValuePathIgnoresNonExistingChoices()
{ {
$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),

View File

@ -19,7 +19,7 @@ use Symfony\Component\Form\Extension\Core\View\ChoiceView;
*/ */
class SimpleChoiceListTest extends AbstractChoiceListTest class SimpleChoiceListTest extends AbstractChoiceListTest
{ {
public function testLegacyInitArray() public function testInitArray()
{ {
$choices = array('a' => 'A', 'b' => 'B', 'c' => 'C'); $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C');
$this->list = new SimpleChoiceList($choices, array('b')); $this->list = new SimpleChoiceList($choices, array('b'));
@ -30,7 +30,7 @@ class SimpleChoiceListTest extends AbstractChoiceListTest
$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 testLegacyInitNestedArray() public function testInitNestedArray()
{ {
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getChoices()); $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getChoices());
$this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues()); $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues());
@ -47,7 +47,7 @@ class SimpleChoiceListTest extends AbstractChoiceListTest
/** /**
* @dataProvider dirtyValuesProvider * @dataProvider dirtyValuesProvider
*/ */
public function testLegacyGetValuesForChoicesDealsWithDirtyValues($choice, $value) public function testGetValuesForChoicesDealsWithDirtyValues($choice, $value)
{ {
$choices = array( $choices = array(
'0' => 'Zero', '0' => 'Zero',

View File

@ -18,32 +18,28 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
*/ */
class SimpleNumericChoiceListTest extends AbstractChoiceListTest class SimpleNumericChoiceListTest extends AbstractChoiceListTest
{ {
public function testLegacyGetIndicesForChoicesDealsWithNumericChoices() public function testGetIndicesForChoicesDealsWithNumericChoices()
{ {
$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 testLegacyGetIndicesForValuesDealsWithNumericValues() public function testGetIndicesForValuesDealsWithNumericValues()
{ {
$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));
} }
public function testLegacyGetChoicesForValuesDealsWithNumericValues() public function testGetChoicesForValuesDealsWithNumericValues()
{ {
// 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->getChoicesForValues($values)); $this->assertSame(array(0, 1), $this->list->getChoicesForValues($values));
} }
public function testLegacyGetValuesForChoicesDealsWithNumericValues() public function testGetValuesForChoicesDealsWithNumericValues()
{ {
// Pass values as strings although they are integers // Pass values as strings although they are integers
$values = array('0', '1'); $values = array('0', '1');

View File

@ -24,8 +24,6 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
protected function setUp() protected function setUp()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
parent::setUp(); parent::setUp();
$this->choiceList = new SimpleChoiceList(array('' => 'Empty', 0 => 'A', 1 => 'B')); $this->choiceList = new SimpleChoiceList(array('' => 'Empty', 0 => 'A', 1 => 'B'));
@ -38,7 +36,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$listener = null; $listener = null;
} }
public function testLegacyFixRadio() public function testFixRadio()
{ {
$data = '1'; $data = '1';
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
@ -51,7 +49,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(2 => '1'), $event->getData()); $this->assertEquals(array(2 => '1'), $event->getData());
} }
public function testLegacyFixZero() public function testFixZero()
{ {
$data = '0'; $data = '0';
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
@ -64,7 +62,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(1 => '0'), $event->getData()); $this->assertEquals(array(1 => '0'), $event->getData());
} }
public function testLegacyFixEmptyString() public function testFixEmptyString()
{ {
$data = ''; $data = '';
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
@ -77,7 +75,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(0 => ''), $event->getData()); $this->assertEquals(array(0 => ''), $event->getData());
} }
public function testLegacyConvertEmptyStringToPlaceholderIfNotFound() public function testConvertEmptyStringToPlaceholderIfNotFound()
{ {
$list = new SimpleChoiceList(array(0 => 'A', 1 => 'B')); $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B'));
@ -91,7 +89,7 @@ class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('placeholder' => ''), $event->getData()); $this->assertEquals(array('placeholder' => ''), $event->getData());
} }
public function testLegacyDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed() public function testDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed()
{ {
$list = new SimpleChoiceList(array(0 => 'A', 1 => 'B')); $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B'));

View File

@ -373,8 +373,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
*/ */
public function testLegacySubmitSingleNonExpandedObjectChoices() public function testLegacySubmitSingleNonExpandedObjectChoices()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$form = $this->factory->create('choice', null, array( $form = $this->factory->create('choice', null, array(
'multiple' => false, 'multiple' => false,
'expanded' => false, 'expanded' => false,
@ -493,8 +491,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
*/ */
public function testLegacySubmitMultipleNonExpandedObjectChoices() public function testLegacySubmitMultipleNonExpandedObjectChoices()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$form = $this->factory->create('choice', null, array( $form = $this->factory->create('choice', null, array(
'multiple' => true, 'multiple' => true,
'expanded' => false, 'expanded' => false,
@ -974,8 +970,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
*/ */
public function testLegacySubmitSingleExpandedObjectChoices() public function testLegacySubmitSingleExpandedObjectChoices()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$form = $this->factory->create('choice', null, array( $form = $this->factory->create('choice', null, array(
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
@ -1202,8 +1196,6 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
*/ */
public function testLegacySubmitMultipleExpandedObjectChoices() public function testLegacySubmitMultipleExpandedObjectChoices()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$form = $this->factory->create('choice', null, array( $form = $this->factory->create('choice', null, array(
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,

View File

@ -640,10 +640,8 @@ class FormTypeTest extends BaseTypeTest
/** /**
* @group legacy * @group legacy
*/ */
public function testLegacyCanGetErrorsWhenButtonInForm() public function testCanGetErrorsWhenButtonInForm()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$builder = $this->factory->createBuilder('form', null, array( $builder = $this->factory->createBuilder('form', null, array(
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
'required' => false, 'required' => false,

View File

@ -736,10 +736,8 @@ class SimpleFormTest extends AbstractFormTest
/** /**
* @group legacy * @group legacy
*/ */
public function testLegacyGetErrorsAsString() public function testGetErrorsAsString()
{ {
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
$this->form->addError(new FormError('Error!')); $this->form->addError(new FormError('Error!'));
$this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString()); $this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString());