Skip to content

Commit e103ebb

Browse files
expect deprecation in tests
1 parent 1b38c73 commit e103ebb

24 files changed

+1022
-25
lines changed

src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\EventDispatcher\EventDispatcher;
1617
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
@@ -28,6 +29,8 @@
2829
*/
2930
abstract class AbstractRequestHandlerTest extends TestCase
3031
{
32+
use ExpectDeprecationTrait;
33+
3134
/**
3235
* @var RequestHandlerInterface
3336
*/
@@ -323,9 +326,12 @@ public function testSubmitFileWithNamelessForm($method)
323326

324327
/**
325328
* @dataProvider getPostMaxSizeFixtures
329+
* @group legacy
326330
*/
327331
public function testAddFormErrorIfPostMaxSizeExceeded(?int $contentLength, string $iniMax, bool $shouldFail, array $errorParams = [])
328332
{
333+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
334+
329335
$this->serverParams->contentLength = $contentLength;
330336
$this->serverParams->postMaxSize = $iniMax;
331337

src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1415
use Doctrine\Common\Collections\ArrayCollection;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -24,6 +25,8 @@
2425

2526
class ResizeFormListenerTest extends TestCase
2627
{
28+
use ExpectDeprecationTrait;
29+
2730
private $factory;
2831
private $form;
2932

@@ -52,8 +55,13 @@ protected function getForm($name = 'name')
5255
return $this->getBuilder($name)->getForm();
5356
}
5457

58+
/**
59+
* @group legacy
60+
*/
5561
public function testPreSetDataResizesForm()
5662
{
63+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
64+
5765
$this->form->add($this->getForm('0'));
5866
$this->form->add($this->getForm('1'));
5967

@@ -86,8 +94,13 @@ public function testPreSetDataDealsWithNullData()
8694
$this->assertSame(0, $this->form->count());
8795
}
8896

97+
/**
98+
* @group legacy
99+
*/
89100
public function testPreSubmitResizesUpIfAllowAdd()
90101
{
102+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
103+
91104
$this->form->add($this->getForm('0'));
92105

93106
$data = [0 => 'string', 1 => 'string'];

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1415
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1516
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
1617
use Symfony\Component\Form\Form;
@@ -20,6 +21,8 @@
2021

2122
class CollectionTypeTest extends BaseTypeTest
2223
{
24+
use ExpectDeprecationTrait;
25+
2326
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CollectionType';
2427

2528
public function testContainsNoChildByDefault()
@@ -31,8 +34,13 @@ public function testContainsNoChildByDefault()
3134
$this->assertCount(0, $form);
3235
}
3336

37+
/**
38+
* @group legacy
39+
*/
3440
public function testSetDataAdjustsSize()
3541
{
42+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
43+
3644
$form = $this->factory->create(static::TESTED_TYPE, null, [
3745
'entry_type' => TextTypeTest::TESTED_TYPE,
3846
'entry_options' => [
@@ -69,8 +77,13 @@ public function testThrowsExceptionIfObjectIsNotTraversable()
6977
$form->setData(new \stdClass());
7078
}
7179

80+
/**
81+
* @group legacy
82+
*/
7283
public function testNotResizedIfSubmittedWithMissingData()
7384
{
85+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
86+
7487
$form = $this->factory->create(static::TESTED_TYPE, null, [
7588
'entry_type' => TextTypeTest::TESTED_TYPE,
7689
]);
@@ -83,8 +96,13 @@ public function testNotResizedIfSubmittedWithMissingData()
8396
$this->assertEquals('', $form[1]->getData());
8497
}
8598

99+
/**
100+
* @group legacy
101+
*/
86102
public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete()
87103
{
104+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
105+
88106
$form = $this->factory->create(static::TESTED_TYPE, null, [
89107
'entry_type' => TextTypeTest::TESTED_TYPE,
90108
'allow_delete' => true,
@@ -98,8 +116,13 @@ public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete()
98116
$this->assertEquals(['foo@foo.com'], $form->getData());
99117
}
100118

119+
/**
120+
* @group legacy
121+
*/
101122
public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty()
102123
{
124+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
125+
103126
$form = $this->factory->create(static::TESTED_TYPE, null, [
104127
'entry_type' => TextTypeTest::TESTED_TYPE,
105128
'allow_delete' => true,
@@ -115,8 +138,13 @@ public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty()
115138
$this->assertEquals(['foo@foo.com'], $form->getData());
116139
}
117140

141+
/**
142+
* @group legacy
143+
*/
118144
public function testResizedDownWithDeleteEmptyCallable()
119145
{
146+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
147+
120148
$form = $this->factory->create(static::TESTED_TYPE, null, [
121149
'entry_type' => AuthorType::class,
122150
'allow_delete' => true,
@@ -134,8 +162,13 @@ public function testResizedDownWithDeleteEmptyCallable()
134162
$this->assertEquals([new Author('Bob')], $form->getData());
135163
}
136164

165+
/**
166+
* @group legacy
167+
*/
137168
public function testResizedDownIfSubmittedWithCompoundEmptyDataDeleteEmptyAndNoDataClass()
138169
{
170+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
171+
139172
$form = $this->factory->create(static::TESTED_TYPE, null, [
140173
'entry_type' => AuthorType::class,
141174
// If the field is not required, no new Author will be created if the
@@ -158,8 +191,13 @@ public function testResizedDownIfSubmittedWithCompoundEmptyDataDeleteEmptyAndNoD
158191
$this->assertEquals([['firstName' => 's_first', 'lastName' => 's_last']], $form->getData());
159192
}
160193

194+
/**
195+
* @group legacy
196+
*/
161197
public function testDontAddEmptyDataIfDeleteEmpty()
162198
{
199+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
200+
163201
$form = $this->factory->create(static::TESTED_TYPE, null, [
164202
'entry_type' => TextTypeTest::TESTED_TYPE,
165203
'allow_add' => true,
@@ -175,8 +213,13 @@ public function testDontAddEmptyDataIfDeleteEmpty()
175213
$this->assertEquals(['foo@foo.com'], $form->getData());
176214
}
177215

216+
/**
217+
* @group legacy
218+
*/
178219
public function testNoDeleteEmptyIfDeleteNotAllowed()
179220
{
221+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
222+
180223
$form = $this->factory->create(static::TESTED_TYPE, null, [
181224
'entry_type' => TextTypeTest::TESTED_TYPE,
182225
'allow_delete' => false,
@@ -190,8 +233,13 @@ public function testNoDeleteEmptyIfDeleteNotAllowed()
190233
$this->assertEquals('', $form[0]->getData());
191234
}
192235

236+
/**
237+
* @group legacy
238+
*/
193239
public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty()
194240
{
241+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
242+
195243
$form = $this->factory->create(static::TESTED_TYPE, null, [
196244
'entry_type' => 'Symfony\Component\Form\Tests\Fixtures\AuthorType',
197245
// If the field is not required, no new Author will be created if the
@@ -235,8 +283,13 @@ public function testNotDeleteEmptyIfInvalid()
235283
$this->assertSame('x', $form[1]->getViewData());
236284
}
237285

286+
/**
287+
* @group legacy
288+
*/
238289
public function testNotResizedIfSubmittedWithExtraData()
239290
{
291+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
292+
240293
$form = $this->factory->create(static::TESTED_TYPE, null, [
241294
'entry_type' => TextTypeTest::TESTED_TYPE,
242295
]);
@@ -248,8 +301,13 @@ public function testNotResizedIfSubmittedWithExtraData()
248301
$this->assertEquals('foo@foo.com', $form[0]->getData());
249302
}
250303

304+
/**
305+
* @group legacy
306+
*/
251307
public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd()
252308
{
309+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
310+
253311
$form = $this->factory->create(static::TESTED_TYPE, null, [
254312
'entry_type' => TextTypeTest::TESTED_TYPE,
255313
'allow_add' => true,
@@ -345,8 +403,13 @@ public function testPrototypeDefaultLabel()
345403
$this->assertSame('__test__label__', $form->createView()->vars['prototype']->vars['label']);
346404
}
347405

406+
/**
407+
* @group legacy
408+
*/
348409
public function testPrototypeData()
349410
{
411+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
412+
350413
$form = $this->factory->create(static::TESTED_TYPE, [], [
351414
'allow_add' => true,
352415
'prototype' => true,
@@ -430,8 +493,13 @@ public function testPrototypeNotOverrideRequiredByEntryOptionsInFavorOfParent()
430493
$this->assertFalse($child->createView()->vars['prototype']->vars['required'], '"Prototype" should not be required');
431494
}
432495

496+
/**
497+
* @group legacy
498+
*/
433499
public function testEntriesBlockPrefixes()
434500
{
501+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
502+
435503
$collectionView = $this->factory->createNamed('fields', static::TESTED_TYPE, [''], [
436504
'allow_add' => true,
437505
])
@@ -450,8 +518,13 @@ public function testEntriesBlockPrefixes()
450518
$this->assertSame($expectedBlockPrefixes, $collectionView->vars['prototype']->vars['block_prefixes']);
451519
}
452520

521+
/**
522+
* @group legacy
523+
*/
453524
public function testEntriesBlockPrefixesWithCustomBlockPrefix()
454525
{
526+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
527+
455528
$collectionView = $this->factory->createNamed('fields', static::TESTED_TYPE, [''], [
456529
'allow_add' => true,
457530
'entry_options' => ['block_prefix' => 'field'],
@@ -494,8 +567,13 @@ public function testEntriesBlockPrefixesWithCustomBlockPrefixedType()
494567
$this->assertSame($expectedBlockPrefixes, $collectionView->vars['prototype']->vars['block_prefixes']);
495568
}
496569

570+
/**
571+
* @group legacy
572+
*/
497573
public function testPrototypeBlockPrefixesWithCustomBlockPrefix()
498574
{
575+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
576+
499577
$collectionView = $this->factory->createNamed('fields', static::TESTED_TYPE, [], [
500578
'allow_add' => true,
501579
'entry_options' => ['block_prefix' => 'field'],

src/Symfony/Component/Form/Tests/Extension/Core/Type/ColorTypeTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,26 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1415
use Symfony\Component\Form\Extension\Core\Type\ColorType;
1516
use Symfony\Component\Form\FormError;
1617

18+
/**
19+
* @group legacy
20+
*/
1721
final class ColorTypeTest extends BaseTypeTest
1822
{
23+
use ExpectDeprecationTrait;
24+
1925
public const TESTED_TYPE = ColorType::class;
2026

27+
protected function setUp(): void
28+
{
29+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
30+
31+
parent::setUp();
32+
}
33+
2134
/**
2235
* @dataProvider validationShouldPassProvider
2336
*/

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1415
use Symfony\Component\Form\FormError;
1516
use Symfony\Component\Form\FormInterface;
1617

1718
class DateTimeTypeTest extends BaseTypeTest
1819
{
20+
use ExpectDeprecationTrait;
21+
1922
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateTimeType';
2023

2124
private $defaultLocale;
@@ -690,9 +693,14 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = [], $expectedDat
690693

691694
/**
692695
* @dataProvider provideEmptyData
696+
* @group legacy
693697
*/
694698
public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedData)
695699
{
700+
if ($widget === 'text' && $emptyData instanceof \Closure) {
701+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
702+
}
703+
696704
$form = $this->factory->create(static::TESTED_TYPE, null, [
697705
'widget' => $widget,
698706
'empty_data' => $emptyData,

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1415
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
1516
use Symfony\Component\Form\FormError;
1617
use Symfony\Component\Form\FormInterface;
@@ -19,6 +20,8 @@
1920

2021
class DateTypeTest extends BaseTypeTest
2122
{
23+
use ExpectDeprecationTrait;
24+
2225
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateType';
2326

2427
private $defaultTimezone;
@@ -1037,9 +1040,14 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = [], $expectedDat
10371040

10381041
/**
10391042
* @dataProvider provideEmptyData
1043+
* @group legacy
10401044
*/
10411045
public function testSubmitNullUsesDateEmptyData($widget, $emptyData, $expectedData)
10421046
{
1047+
if ($widget === 'text' && $emptyData instanceof \Closure) {
1048+
$this->expectDeprecation('Since symfony/form 6.0: The default value of "empty_data" option in "Symfony\Component\Form\Extension\Core\Type\TextType" will be changed to empty string. Declare "NULL" as value for "empty_data" if you still want use "NULL" as data.');
1049+
}
1050+
10431051
$form = $this->factory->create(static::TESTED_TYPE, null, [
10441052
'widget' => $widget,
10451053
'empty_data' => $emptyData,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy