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 7cde0cc

Browse filesBrowse files
Merge branch '8.1' into 8.2
* 8.1: Make tests compatible with PHPUnit 13.2 and Twig 3.28 Fix test [Serializer] Keep collection value type for iterable constructor parameters [AssetMapper] Render an empty import map as a JSON object [Translation] Fix test failing without the intl extension [Mailer] [Mailchimp] Fix tests on low-deps [HttpFoundation] Add RFC6598 Shared Address Space to IpUtils::PRIVATE_SUBNETS Fix Content-Type key in createRequest method
2 parents a847257 + 706f9b2 commit 7cde0cc
Copy full SHA for 7cde0cc

21 files changed

+155-53Lines changed: 155 additions & 53 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
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2020
use Twig\DeprecatedCallableInfo;
2121
use Twig\Environment;
22+
use Twig\Error\Error;
2223
use Twig\Loader\ArrayLoader;
2324
use Twig\TwigFilter;
2425

@@ -100,11 +101,14 @@ public static function getValidValues()
100101

101102
public static function getInvalidValues()
102103
{
104+
// Twig 3.28 started reporting the column number in syntax errors
105+
$column = method_exists(Error::class, 'getTemplateColumn') ? ' column 14' : '';
106+
103107
return [
104108
// Invalid syntax example (missing end tag)
105109
['{% if condition %}Oops', 'Unexpected end of template at line 1.', 1],
106110
// Another syntax error example (unclosed variable)
107-
['Hello {{ name', 'Unexpected token "end of template" ("end of print statement" expected) at line 1.', 1],
111+
['Hello {{ name', \sprintf('Unexpected token "end of template" ("end of print statement" expected) at line 1%s.', $column), 1],
108112
// Unknown filter error
109113
['Hello {{ name|unknown_filter }}', 'Unknown "unknown_filter" filter at line 1.', 1],
110114
// Invalid variable syntax
Collapse file

‎src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function render(string|array $entryPoint, array $attributes = []): string
104104
}
105105

106106
$scriptAttributes = $attributes || $this->scriptAttributes ? ' '.$this->createAttributesString($attributes) : '';
107-
$importMapJson = json_encode(['imports' => $importMap], \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_HEX_TAG);
107+
$importMapJson = json_encode(['imports' => $importMap ?: new \stdClass()], \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_HEX_TAG);
108108
$output .= <<<HTML
109109
110110
<script type="importmap"$scriptAttributes>
Collapse file

‎src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapRendererTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapRendererTest.php
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,19 @@ public function testItAddsPreloadLinks()
229229
$this->assertSame(['as' => 'style'], $linkProvider->getLinks()[0]->getAttributes());
230230
$this->assertSame('/assets/styles/app-preload-d1g35t.css', $linkProvider->getLinks()[0]->getHref());
231231
}
232+
233+
public function testEmptyImportMapRendersAsJsonObject()
234+
{
235+
$importMapGenerator = $this->createMock(ImportMapGenerator::class);
236+
$importMapGenerator->expects($this->once())
237+
->method('getImportMapData')
238+
->with([])
239+
->willReturn([]);
240+
241+
$renderer = new ImportMapRenderer($importMapGenerator);
242+
$html = $renderer->render([]);
243+
244+
$this->assertStringContainsString('"imports": {}', $html);
245+
$this->assertStringNotContainsString('"imports": []', $html);
246+
}
232247
}
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/HttpFoundation/IpUtils.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/IpUtils.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class IpUtils
2626
'169.254.0.0/16', // RFC3927
2727
'0.0.0.0/8', // RFC5735
2828
'240.0.0.0/4', // RFC1112
29+
'100.64.0.0/10', // RFC6598
2930
'::1/128', // Loopback
3031
'fc00::/7', // Unique Local Address
3132
'fe80::/10', // Link Local Address

0 commit comments

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