8000 [Form] Fixed tests using legacy functionality · symfony/symfony@1d89922 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d89922

Browse files
committed
[Form] Fixed tests using legacy functionality
1 parent d6179c8 commit 1d89922

25 files changed

+210
-188
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ public function configureOptions(OptionsResolver $resolver)
228228

229229
// deprecation note
230230
$propertyNormalizer = function (Options $options, $propertyName) {
231-
trigger_error('The "property" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_label" instead.', E_USER_DEPRECATED);
231+
if ($propertyName) {
232+
trigger_error('The "property" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_label" instead.', E_USER_DEPRECATED);
233+
}
232234

233235
return $propertyName;
234236
};
@@ -249,7 +251,9 @@ public function configureOptions(OptionsResolver $resolver)
249251

250252
// deprecation note
251253
$loaderNormalizer = function (Options $options, $loader) {
252-
trigger_error('The "loader" option is deprecated since version 2.7 and will be removed in 3.0. Override getLoader() instead.', E_USER_DEPRECATED);
254+
if ($loader) {
255+
trigger_error('The "loader" option is deprecated since version 2.7 and will be removed in 3.0. Override getLoader() instead.', E_USER_DEPRECATED);
256+
}
253257

254258
return $loader;
255259
};
@@ -300,6 +304,7 @@ public function configureOptions(OptionsResolver $resolver)
300304

301305
$resolver->setAllowedTypes('em', array('null', 'string', 'Doctrine\Common\Persistence\ObjectManager'));
302306
$resolver->setAllowedTypes('loader', array('null', 'Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface'));
307+
$resolver->setAllowedTypes('query_builder', array('null', 'callable', 'Doctrine\ORM\QueryBuilder'));
303308
}
304309

305310
/**

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
2020
use Doctrine\ORM\Tools\SchemaTool;
2121

22+
/**
23+
* @group legacy
24+
*/
2225
class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
2326
{
2427
const SINGLE_INT_ID_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity';
@@ -36,6 +39,8 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
3639

3740
protected function setUp()
3841
{
42+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
43+
3944
$this->em = DoctrineTestHelper::createTestEntityManager();
4045

4146
$schemaTool = new SchemaTool($this->em);
@@ -70,7 +75,7 @@ protected function tearDown()
7075
* @expectedException \Symfony\Component\Form\Exception\StringCastException
7176
* @expectedMessage Entity "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity" passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).
7277
*/
73-
public function testEntitiesMustHaveAToStringMethod()
78+
public function testLegacyEntitiesMustHaveAToStringMethod()
7479
{
7580
$entity1 = new SingleIntIdNoToStringEntity(1, 'Foo');
7681
$entity2 = new SingleIntIdNoToStringEntity(2, 'Bar');
@@ -96,7 +101,7 @@ public function testEntitiesMustHaveAToStringMethod()
96101
/**
97102
* @expectedException \Symfony\Component\Form\Exception\RuntimeException
98103
*/
99-
public function testChoicesMustBeManaged()
104+
public function testLegacyChoicesMustBeManaged()
100105
{
101106
$entity1 = new SingleIntIdEntity(1, 'Foo');
102107
$entity2 = new SingleIntIdEntity(2, 'Bar');
@@ -118,7 +123,7 @@ public function testChoicesMustBeManaged()
118123
$choiceList->getChoices();
119124
}
120125

121-
public function testInitExplicitChoices()
126+
public function testLegacyInitExplicitChoices()
122127
{
123128
$entity1 = new SingleIntIdEntity(1, 'Foo');
124129
$entity2 = new SingleIntIdEntity(2, 'Bar');
@@ -141,7 +146,7 @@ public function testInitExplicitChoices()
141146
$this->assertSame(array(1 => $entity1, 2 => $entity2), $choiceList->getChoices());
142147
}
143148

144-
public function testInitEmptyChoices()
149+
public function testLegacyInitEmptyChoices()
145150
{
146151
$entity1 = new SingleIntIdEntity(1, 'Foo');
147152
$entity2 = new SingleIntIdEntity(2, 'Bar');
@@ -161,7 +166,7 @@ public function testInitEmptyChoices()
161166
$this->assertSame(array(), $choiceList->getChoices());
162167
}
163168

164-
public function testInitNestedChoices()
169+
public function testLegacyInitNestedChoices()
165170
{
166171
$entity1 = new SingleIntIdEntity(1, 'Foo');
167172
$entity2 = new SingleIntIdEntity(2, 'Bar');
@@ -189,7 +194,7 @@ public function testInitNestedChoices()
189194
), $choiceList->getRemainingViews());
190195
}
191196

192-
public function testGroupByPropertyPath()
197+
public function testLegacyGroupByPropertyPath()
193198
{
194199
$item1 = new GroupableEntity(1, 'Foo', 'Group1');
195200
$item2 = new GroupableEntity(2, 'Bar', 'Group1');
@@ -224,7 +229,7 @@ public function testGroupByPropertyPath()
224229
), $choiceList->getRemainingViews());
225230
}
226231

227-
public function testGroupByInvalidPropertyPathReturnsFlatChoices()
232+
public function testLegacyGroupByInvalidPropertyPathReturnsFlatChoices()
228233
{
229234
$item1 = new GroupableEntity(1, 'Foo', 'Group1');
230235
$item2 = new GroupableEntity(2, 'Bar', 'Group1');
@@ -251,7 +256,7 @@ public function testGroupByInvalidPropertyPathReturnsFlatChoices()
251256
), $choiceList->getChoices());
252257
}
253258

254-
public function testInitShorthandEntityName()
259+
public function testLegacyInitShorthandEntityName()
255260
{
256261
$item1 = new SingleIntIdEntity(1, 'Foo');
257262
$item2 = new SingleIntIdEntity(2, 'Bar');
@@ -267,13 +272,8 @@ public function testInitShorthandEntityName()
267272
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
268273
}
269274

270-
/**
271-
* @group legacy
272-
*/
273-
public function testLegacyInitShorthandEntityName()
275+
public function testLegacyInitShorthandEntityName2()
274276
{
275-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
276-
277277
$item1 = new SingleIntIdEntity(1, 'Foo');
278278
$item2 = new SingleIntIdEntity(2, 'Bar');
279279

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListCompositeIdTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
16+
* @group legacy
1617
*/
1718
class LoadedEntityChoiceListCompositeIdTest extends AbstractEntityChoiceListCompositeIdTest
1819
{

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListSingleIntIdTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
16+
* @group legacy
1617
*/
1718
class LoadedEntityChoiceListSingleIntIdTest extends AbstractEntityChoiceListSingleIntIdTest
1819
{

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/LoadedEntityChoiceListSingleStringIdTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
16+
* @group legacy
1617
*/
1718
class LoadedEntityChoiceListSingleStringIdTest extends AbstractEntityChoiceListSingleStringIdTest
1819
{

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListCompositeIdTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
16+
* @group legacy
1617
*/
1718
class UnloadedEntityChoiceListCompositeIdTest extends AbstractEntityChoiceListCompositeIdTest
1819
{
19-
public function testGetIndicesForValuesIgnoresNonExistingValues()
20+
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
2021
{
2122
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
2223
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListCompositeIdWithQueryBuilderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* @author Bernhard Schussek <bschussek@gmail.com>
19+
* @group legacy
1920
*/
2021
class UnloadedEntityChoiceListCompositeIdWithQueryBuilderTest extends UnloadedEntityChoiceListCompositeIdTest
2122
{

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,10 @@
1313

1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
16+
* @group legacy
1617
*/
1718
class UnloadedEntityChoiceListSingleIntIdTest extends AbstractEntityChoiceListSingleIntIdTest
1819
{
19-
public function testGetIndicesForValuesIgnoresNonExistingValues()
20-
{
21-
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
22-
}
23-
24-
/**
25-
* @group legacy
26-
*/
2720
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
2821
{
2922
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdWithQueryBuilderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* @author Bernhard Schussek <bschussek@gmail.com>
19+
* @group legacy
1920
*/
2021
class UnloadedEntityChoiceListSingleIntIdWithQueryBuilderTest extends UnloadedEntityChoiceListSingleIntIdTest
2122
{

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleStringIdTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
/**
1515
* @author Bernhard Schussek <bschussek@gmail.com>
16+
* @group legacy
1617
*/
1718
class UnloadedEntityChoiceListSingleStringIdTest extends AbstractEntityChoiceListSingleStringIdTest
1819
{
19-
public function testGetIndicesForValuesIgnoresNonExistingValues()
20+
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
2021
{
2122
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
2223
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleStringIdWithQueryBuilderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* @author Bernhard Schussek <bschussek@gmail.com>
19+
* @group legacy
1920
*/
2021
class UnloadedEntityChoiceListSingleStringIdWithQueryBuilderTest extends UnloadedEntityChoiceListSingleStringIdTest
2122
{

0 commit comments

Comments
 (0)
0