Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1b9b428

Browse filesBrowse files
Make tests compatible with PHPUnit 13.2 and Twig 3.28
1 parent 0e92289 commit 1b9b428
Copy full SHA for 1b9b428

12 files changed

+92-51Lines changed: 92 additions & 51 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,19 @@ public function testLoadChoiceList()
7373
);
7474

7575
$choices = [$this->obj1, $this->obj2, $this->obj3];
76-
$value = static function () {};
77-
$choiceList = new ArrayChoiceList($choices, $value);
76+
$value = static fn ($choice) => $choice->name;
7877

7978
$this->repository->expects($this->once())
8079
->method('findAll')
8180
->willReturn($choices);
8281

83-
$this->assertEquals($choiceList, $loader->loadChoiceList($value));
82+
$expected = ['A' => $this->obj1, 'B' => $this->obj2, 'C' => $this->obj3];
83+
84+
$this->assertSame($expected, $loader->loadChoiceList($value)->getChoices());
8485

8586
// no further loads on subsequent calls
8687

87-
$this->assertEquals($choiceList, $loader->loadChoiceList($value));
88+
$this->assertSame($expected, $loader->loadChoiceList($value)->getChoices());
8889
}
8990

9091
public function testLoadChoiceListUsesObjectLoaderIfAvailable()
Collapse file

‎src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Validator/Constraints/TwigValidatorTest.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1919
use Twig\DeprecatedCallableInfo;
2020
use Twig\Environment;
21+
use Twig\Error\Error;
2122
use Twig\Loader\ArrayLoader;
2223
use Twig\TwigFilter;
2324

@@ -109,11 +110,14 @@ public static function getValidValues()
109110

110111
public static function getInvalidValues()
111112
{
113+
// Twig 3.28 started reporting the column number in syntax errors
114+
$column = method_exists(Error::class, 'getTemplateColumn') ? ' column 14' : '';
115+
112116
return [
113117
// Invalid syntax example (missing end tag)
114118
['{% if condition %}Oops', 'Unexpected end of template at line 1.', 1],
115119
// Another syntax error example (unclosed variable)
116-
['Hello {{ name', 'Unexpected token "end of template" ("end of print statement" expected) at line 1.', 1],
120+
['Hello {{ name', \sprintf('Unexpected token "end of template" ("end of print statement" expected) at line 1%s.', $column), 1],
117121
// Unknown filter error
118122
['Hello {{ name|unknown_filter }}', 'Unknown "unknown_filter" filter at line 1.', 1],
119123
// Invalid variable syntax
Collapse file

‎src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ public function testGetListenersSortsByPriority()
7070
$this->dispatcher->addListener('pre.foo', [$listener1, 'preFoo'], -10);
7171
$this->dispatcher->addListener('pre.foo', [$listener2, 'preFoo'], 10);
7272
$this->dispatcher->addListener('pre.foo', [$listener3, 'preFoo']);
73-
$this->dispatcher->addListener('pre.foo', $listener4->preFoo(...), 20);
73+
$this->dispatcher->addListener('pre.foo', $listener4Listener = $listener4->preFoo(...), 20);
7474

7575
$expected = [
76-
$listener4->preFoo(...),
76+
$listener4Listener,
7777
[$listener2, 'preFoo'],
7878
[$listener3, 'preFoo'],
7979
[$listener1, 'preFoo'],
8080
];
8181

82-
$this->assertEquals($expected, $this->dispatcher->getListeners('pre.foo'));
82+
$this->assertSame($expected, $this->dispatcher->getListeners('pre.foo'));
8383
}
8484

8585
public function testGetAllListenersSortsByPriority()
Collapse file

‎src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function testCreateFromLoaderWithValues()
255255
$value = static function () {};
256256
$list = $this->factory->createListFromLoader($loader, $value);
257257

258-
$this->assertEquals(new LazyChoiceList($loader, $value), $list);
258+
$this->assertEqualsLazyChoiceList(new LazyChoiceList($loader, $value), $list);
259259
}
260260

261261
public function testCreateFromLoaderWithFilter()
Collapse file

‎src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php
+33-22Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testBuildPreliminaryFormTree()
5959
'type_class' => FormType::class,
6060
'synchronized' => true,
6161
'passed_options' => [],
62-
'resolved_options' => $this->childForm->getConfig()->getOptions(),
62+
'resolved_options' => self::removeClosures($this->childForm->getConfig()->getOptions()),
6363
'default_data' => [
6464
'norm' => null,
6565
'view' => '',
@@ -78,7 +78,7 @@ public function testBuildPreliminaryFormTree()
7878
'type_class' => FormType::class,
7979
'synchronized' => true,
8080
'passed_options' => [],
81-
'resolved_options' => $this->form->getConfig()->getOptions(),
81+
'resolved_options' => self::removeClosures($this->form->getConfig()->getOptions()),
8282
'default_data' => [
8383
'norm' => null,
8484
],
@@ -101,7 +101,7 @@ public function testBuildPreliminaryFormTree()
101101
spl_object_hash($this->childForm) => $childFormData,
102102
],
103103
'nb_errors' => 0,
104-
], $this->dataCollector->getData());
104+
], self::removeClosures($this->dataCollector->getData()));
105105
}
106106

107107
public function testBuildMultiplePreliminaryFormTrees()
@@ -119,7 +119,7 @@ public function testBuildMultiplePreliminaryFormTrees()
119119
'type_class' => FormType::class,
120120
'synchronized' => true,
121121
'passed_options' => [],
122-
'resolved_options' => $form1->getConfig()->getOptions(),
122+
'resolved_options' => self::removeClosures($form1->getConfig()->getOptions()),
123123
'children' => [],
124124
];
125125

@@ -131,7 +131,7 @@ public function testBuildMultiplePreliminaryFormTrees()
131131
spl_object_hash($form1) => $form1Data,
132132
],
133133
'nb_errors' => 0,
134-
], $this->dataCollector->getData());
134+
], self::removeClosures($this->dataCollector->getData()));
135135

136136
$this->dataCollector->buildPreliminaryFormTree($form2);
137137

@@ -141,7 +141,7 @@ public function testBuildMultiplePreliminaryFormTrees()
141141
'type_class' => FormType::class,
142142
'synchronized' => true,
143143
'passed_options' => [],
144-
'resolved_options' => $form2->getConfig()->getOptions(),
144+
'resolved_options' => self::removeClosures($form2->getConfig()->getOptions()),
145145
'children' => [],
146146
];
147147

@@ -155,7 +155,7 @@ public function testBuildMultiplePreliminaryFormTrees()
155155
spl_object_hash($form2) => $form2Data,
156156
],
157157
'nb_errors' => 0,
158-
], $this->dataCollector->getData());
158+
], self::removeClosures($this->dataCollector->getData()));
159159
}
160160

161161
public function testBuildSamePreliminaryFormTreeMultipleTimes()
@@ -169,7 +169,7 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes()
169169
'type_class' => FormType::class,
170170
'synchronized' => true,
171171
'passed_options' => [],
172-
'resolved_options' => $this->form->getConfig()->getOptions(),
172+
'resolved_options' => self::removeClosures($this->form->getConfig()->getOptions()),
173173
'children' => [],
174174
];
175175

@@ -181,7 +181,7 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes()
181181
spl_object_hash($this->form) => $formData,
182182
],
183183
'nb_errors' => 0,
184-
], $this->dataCollector->getData());
184+
], self::removeClosures($this->dataCollector->getData()));
185185

186186
$this->dataCollector->collectDefaultData($this->form);
187187
$this->dataCollector->buildPreliminaryFormTree($this->form);
@@ -192,7 +192,7 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes()
192192
'type_class' => FormType::class,
193193
'synchronized' => true,
194194
'passed_options' => [],
195-
'resolved_options' => $this->form->getConfig()->getOptions(),
195+
'resolved_options' => self::removeClosures($this->form->getConfig()->getOptions()),
196196
'default_data' => [
197197
'norm' => null,
198198
],
@@ -208,7 +208,7 @@ public function testBuildSamePreliminaryFormTreeMultipleTimes()
208208
spl_object_hash($this->form) => $formData,
209209
],
210210
'nb_errors' => 0,
211-
], $this->dataCollector->getData());
211+
], self::removeClosures($this->dataCollector->getData()));
212212
}
213213

214214
public function testBuildPreliminaryFormTreeWithoutCollectingAnyData()
@@ -227,7 +227,7 @@ public function testBuildPreliminaryFormTreeWithoutCollectingAnyData()
227227
spl_object_hash($this->form) => $formData,
228228
],
229229
'nb_errors' => 0,
230-
], $this->dataCollector->getData());
230+
], self::removeClosures($this->dataCollector->getData()));
231231
}
232232

233233
public function testBuildFinalFormTree()
@@ -247,7 +247,7 @@ public function testBuildFinalFormTree()
247247
'type_class' => FormType::class,
248248
'synchronized' => true,
249249
'passed_options' => [],
250-
'resolved_options' => $this->childForm->getConfig()->getOptions(),
250+
'resolved_options' => self::removeClosures($this->childForm->getConfig()->getOptions()),
251251
'default_data' => [
252252
'norm' => null,
253253
'view' => '',
@@ -270,7 +270,7 @@ public function testBuildFinalFormTree()
270270
'type_class' => FormType::class,
271271
'synchronized' => true,
272272
'passed_options' => [],
273-
'resolved_options' => $this->form->getConfig()->getOptions(),
273+
'resolved_options' => self::removeClosures($this->form->getConfig()->getOptions()),
274274
'default_data' => [
275275
'norm' => null,
276276
],
@@ -297,7 +297,7 @@ public function testBuildFinalFormTree()
297297
spl_object_hash($this->childForm) => $childFormData,
298298
],
299299
'nb_errors' => 0,
300-
], $this->dataCollector->getData());
300+
], self::removeClosures($this->dataCollector->getData()));
301301
}
302302

303303
public function testSerializeWithFormAddedMultipleTimes()
@@ -368,7 +368,7 @@ public function testFinalFormReliesOnFormViewStructure()
368368
spl_object_hash($child2) => $child2Data,
369369
],
370370
'nb_errors' => 0,
371-
], $this->dataCollector->getData());
371+
], self::removeClosures($this->dataCollector->getData()));
372372

373373
$this->dataCollector->buildFinalFormTree($this->form, $this->view);
374374

@@ -389,7 +389,7 @@ public function testFinalFormReliesOnFormViewStructure()
389389
spl_object_hash($child2) => $child2Data,
390390
],
391391
'nb_errors' => 0,
392-
], $this->dataCollector->getData());
392+
], self::removeClosures($this->dataCollector->getData()));
393393
}
394394

395395
public function testChildViewsCanBeWithoutCorrespondingChildForms()
@@ -415,7 +415,7 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms()
415415
'type_class' => FormType::class,
416416
'synchronized' => true,
417417
'passed_options' => [],
418-
'resolved_options' => $this->form->getConfig()->getOptions(),
418+
'resolved_options' => self::removeClosures($this->form->getConfig()->getOptions()),
419419
'children' => [
420420
'child' => $childFormData,
421421
],
@@ -430,7 +430,7 @@ public function testChildViewsCanBeWithoutCorrespondingChildForms()
430430
// no child entry
431431
],
432432
'nb_errors' => 0,
433-
], $this->dataCollector->getData());
433+
], self::removeClosures($this->dataCollector->getData()));
434434
}
435435

436436
public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssociated()
@@ -454,7 +454,7 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc
454454
'type_class' => FormType::class,
455455
'synchronized' => true,
456456
'passed_options' => [],
457-
'resolved_options' => $this->childForm->getConfig()->getOptions(),
457+
'resolved_options' => self::removeClosures($this->childForm->getConfig()->getOptions()),
458458
'children' => [],
459459
];
460460

@@ -464,7 +464,7 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc
464464
'type_class' => FormType::class,
465465
'synchronized' => true,
466466
'passed_options' => [],
467-
'resolved_options' => $this->form->getConfig()->getOptions(),
467+
'resolved_options' => self::removeClosures($this->form->getConfig()->getOptions()),
468468
'children' => [
469469
'child' => $childFormData,
470470
],
@@ -479,7 +479,7 @@ public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssoc
479479
spl_object_hash($this->childForm) => $childFormData,
480480
],
481481
'nb_errors' => 0,
482-
], $this->dataCollector->getData());
482+
], self::removeClosures($this->dataCollector->getData()));
483483
}
484484

485485
public function testCollectSubmittedDataCountsErrors()
@@ -615,4 +615,15 @@ private function createChildForm(string $name, bool $compound = false): FormInte
615615
{
616616
return $this->factory->createNamedBuilder($name, FormType::class, null, ['auto_initialize' => false, 'compound' => $compound])->getForm();
617617
}
618+
619+
private static function removeClosures(array $data): array
620+
{
621+
array_walk_recursive($data, static function (&$value) {
622+
if ($value instanceof \Closure) {
623+
$value = '(closure)';
624+
}
625+
});
626+
627+
return $data;
628+
}
618629
}
Collapse file

‎src/Symfony/Component/HtmlSanitizer/Tests/TextSanitizer/StringSanitizerTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/HtmlSanitizer/Tests/TextSanitizer/StringSanitizerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function provideEncodeHtmlEntites()
6161
];
6262

6363
foreach ($cases as $input => $expected) {
64-
yield $input => [$input, $expected];
64+
yield ('' === $input ? 'empty string' : $input) => [$input, $expected];
6565
}
6666
}
6767

Collapse file

‎src/Symfony/Component/HtmlSanitizer/Tests/TextSanitizer/UrlSanitizerTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/HtmlSanitizer/Tests/TextSanitizer/UrlSanitizerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ public static function provideParse(): iterable
881881
];
882882

883883
foreach ($urls as $url => $expected) {
884-
yield $url => [$url, $expected];
884+
yield ('' === $url ? 'empty string' : $url) => [$url, $expected];
885885
}
886886
}
887887
}
Collapse file

‎src/Symfony/Component/JsonStreamer/Tests/Mapping/Read/AttributePropertyMetadataLoaderTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/JsonStreamer/Tests/Mapping/Read/AttributePropertyMetadataLoaderTest.php
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,21 @@ public function testRetrieveValueTransformer()
4141
StringToBooleanValueTransformer::class => new StringToBooleanValueTransformer(),
4242
]), TypeResolver::create());
4343

44-
$this->assertEquals([
45-
'id' => new PropertyMetadata('id', Type::string(), [DivideStringAndCastToIntValueTransformer::class]),
46-
'active' => new PropertyMetadata('active', Type::string(), [StringToBooleanValueTransformer::class]),
47-
'name' => new PropertyMetadata('name', Type::string(), [\Closure::fromCallable('strtoupper')]),
48-
'range' => new PropertyMetadata('range', Type::string(), [\Closure::fromCallable(DummyWithValueTransformerAttributes::explodeRange(...))]),
49-
], $loader->load(DummyWithValueTransformerAttributes::class));
44+
$metadata = $loader->load(DummyWithValueTransformerAttributes::class);
45+
46+
$this->assertSame(['id', 'active', 'name', 'range'], array_keys($metadata));
47+
$this->assertEquals(new PropertyMetadata('id', Type::string(), [DivideStringAndCastToIntValueTransformer::class]), $metadata['id']);
48+
$this->assertEquals(new PropertyMetadata('active', Type::string(), [StringToBooleanValueTransformer::class]), $metadata['active']);
49+
50+
$this->assertSame('name', $metadata['name']->getName());
51+
$this->assertEquals(Type::string(), $metadata['name']->getType());
52+
$this->assertCount(1, $metadata['name']->getValueTransformers());
53+
$this->assertSame('FOO', $metadata['name']->getValueTransformers()[0]('foo'));
54+
55+
$this->assertSame('range', $metadata['range']->getName());
56+
$this->assertEquals(Type::string(), $metadata['range']->getType());
57+
$this->assertCount(1, $metadata['range']->getValueTransformers());
58+
$this->assertSame([1, 2], $metadata['range']->getValueTransformers()[0]('1..2'));
5059
}
5160

5261
public function testThrowWhenCannotRetrieveValueTransformer()
Collapse file

‎src/Symfony/Component/JsonStreamer/Tests/Mapping/Write/AttributePropertyMetadataLoaderTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/JsonStreamer/Tests/Mapping/Write/AttributePropertyMetadataLoaderTest.php
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,21 @@ public function testRetrieveValueTransformer()
4141
BooleanToStringValueTransformer::class => new BooleanToStringValueTransformer(),
4242
]), TypeResolver::create());
4343

44-
$this->assertEquals([
45-
'id' => new PropertyMetadata('id', Type::string(), [DoubleIntAndCastToStringValueTransformer::class]),
46-
'active' => new PropertyMetadata('active', Type::string(), [BooleanToStringValueTransformer::class]),
47-
'name' => new PropertyMetadata('name', Type::string(), [\Closure::fromCallable('strtolower')]),
48-
'range' => new PropertyMetadata('range', Type::string(), [\Closure::fromCallable(DummyWithValueTransformerAttributes::concatRange(...))]),
49-
], $loader->load(DummyWithValueTransformerAttributes::class));
44+
$metadata = $loader->load(DummyWithValueTransformerAttributes::class);
45+
46+
$this->assertSame(['id', 'active', 'name', 'range'], array_keys($metadata));
47+
$this->assertEquals(new PropertyMetadata('id', Type::string(), [DoubleIntAndCastToStringValueTransformer::class]), $metadata['id']);
48+
$this->assertEquals(new PropertyMetadata('active', Type::string(), [BooleanToStringValueTransformer::class]), $metadata['active']);
49+
50+
$this->assertSame('name', $metadata['name']->getName());
51+
$this->assertEquals(Type::string(), $metadata['name']->getType());
52+
$this->assertCount(1, $metadata['name']->getValueTransformers());
53+
$this->assertSame('foo', $metadata['name']->getValueTransformers()[0]('FOO'));
54+
55+
$this->assertSame('range', $metadata['range']->getName());
56+
$this->assertEquals(Type::string(), $metadata['range']->getType());
57+
$this->assertCount(1, $metadata['range']->getValueTransformers());
58+
$this->assertSame('10..20', $metadata['range']->getValueTransformers()[0]([10, 20]));
5059
}
5160

5261
public function testThrowWhenCannotRetrieveValueTransformer()
Collapse file

‎src/Symfony/Component/Messenger/Tests/Handler/HandlersLocatorTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Handler/HandlersLocatorTest.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ public function testItYieldsHandlerDescriptors()
2828
]);
2929

3030
$descriptor = new HandlerDescriptor($handler);
31-
$descriptor->getName();
3231

33-
$this->assertEquals([$descriptor], iterator_to_array($locator->getHandlers(new Envelope(new DummyMessage('a')))));
32+
$handlers = iterator_to_array($locator->getHandlers(new Envelope(new DummyMessage('a'))));
33+
34+
$this->assertCount(1, $handlers);
35+
$this->assertSame($descriptor->getName(), $handlers[0]->getName());
36+
$this->assertSame($handler, (new \ReflectionFunction($handlers[0]->getHandler()))->getClosureThis());
3437
}
3538

3639
public function testItReturnsOnlyHandlersMatchingTransport()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.