Skip to content

Commit ed7bb82

Browse files
Merge branch '3.4' into 4.4
* 3.4: [Phpunit] Fix running skipped tests expecting only deprecations [DependencyInjection] #35505 Fix typo in test name [Yaml][Inline] Fail properly on empty object tag and empty const tag Check non-null type for numeric type Check value isset to avoid PHP notice bug #28179 [DomCrawler] Skip disabled fields processing in Form
2 parents 774a161 + af46fd6 commit ed7bb82

File tree

9 files changed

+103
-22
lines changed

9 files changed

+103
-22
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

+4
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ public function startTest($test)
211211
}
212212
}
213213

214+
if (!$test->getTestResultObject()) {
215+
return;
216+
}
217+
214218
$annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
215219

216220
if (isset($annotations['class']['expectedDeprecation'])) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* This test is meant to be skipped.
18+
*
19+
* @requires extension ext-dummy
20+
*/
21+
final class OnlyExpectingDeprecationSkippedTest extends TestCase
22+
{
23+
/**
24+
* Do not remove this test in the next major versions.
25+
*
26+
* @group legacy
27+
*
28+
* @expectedDeprecation unreachable
29+
*/
30+
public function testExpectingOnlyDeprecations()
31+
{
32+
$this->fail('should never be ran.');
33+
}
34+
}

src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ public function templateAction(string $template, int $maxAge = null, int $shared
5555
throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
5656
}
5757

58-
if ($maxAge) {
58+
if (null !== $maxAge) {
5959
$response->setMaxAge($maxAge);
6060
}
6161

62-
if ($sharedAge) {
62+
if (null !== $sharedAge) {
6363
$response->setSharedMaxAge($sharedAge);
6464
}
6565

6666
if ($private) {
6767
$response->setPrivate();
68-
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
68+
} elseif (false === $private || (null === $private && (null !== $maxAge || null !== $sharedAge))) {
6969
$response->setPublic();
7070
}
7171

src/Symfony/Component/Console/Style/SymfonyStyle.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public function choice($question, array $choices, $default = null)
295295
{
296296
if (null !== $default) {
297297
$values = array_flip($choices);
298-
$default = $values[$default];
298+
$default = isset($values[$default]) ? $values[$default] : $default;
299299
}
300300

301301
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ public function testThrowsExceptionWhenSetServiceOnACompiledContainer()
10971097
$container->set('a', new \stdClass());
10981098
}
10991099

1100-
public function testThrowsExceptionWhenAddServiceOnACompiledContainer()
1100+
public function testNoExceptionWhenAddServiceOnACompiledContainer()
11011101
{
11021102
$container = new ContainerBuilder();
11031103
$container->compile();

src/Symfony/Component/DomCrawler/Form.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ public function getValues()
8989
{
9090
$values = [];
9191
foreach ($this->fields->all() as $name => $field) {
92-
if ($field->isDisabled()) {
93-
continue;
94-
}
95-
9692
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
9793
$values[$name] = $field->getValue();
9894
}
@@ -115,10 +111,6 @@ public function getFiles()
115111
$files = [];
116112

117113
foreach ($this->fields->all() as $name => $field) {
118-
if ($field->isDisabled()) {
119-
continue;
120-
}
121-
122114
if ($field instanceof Field\FileFormField) {
123115
$files[$name] = $field->getValue();
124116
}
@@ -473,7 +465,7 @@ private function initialize()
473465

474466
private function addField(\DOMElement $node)
475467
{
476-
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
468+
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
477469
return;
478470
}
479471

src/Symfony/Component/DomCrawler/Tests/FormTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ public function testConstructorHandlesFormValues()
158158
public function testMultiValuedFields()
159159
{
160160
$form = $this->createForm('<form>
161-
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
162-
<input type="text" name="foo" value="foo" disabled="disabled" />
163-
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
164-
<input type="text" name="foo[]" value="foo" disabled="disabled" />
165-
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
166-
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
161+
<input type="text" name="foo[4]" value="foo" />
162+
<input type="text" name="foo" value="foo" />
163+
<input type="text" name="foo[2]" value="foo" />
164+
<input type="text" name="foo[]" value="foo" />
165+
<input type="text" name="bar[foo][]" value="foo" />
166+
<input type="text" name="bar[foo][foobar]" value="foo" />
167167
<input type="submit" />
168168
</form>
169169
');
@@ -226,10 +226,10 @@ public function provideInitializeValues()
226226
[],
227227
],
228228
[
229-
'takes into account disabled input fields',
229+
'skips disabled input fields',
230230
'<input type="text" name="foo" value="foo" disabled="disabled" />
231231
<input type="submit" />',
232-
['foo' => ['InputFormField', 'foo']],
232+
[],
233233
],
234234
[
235235
'appends the submitted button value',

src/Symfony/Component/Yaml/Inline.php

+8
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
589589
return substr($scalar, 2);
590590
case 0 === strpos($scalar, '!php/object'):
591591
if (self::$objectSupport) {
592+
if (!isset($scalar[12])) {
593+
return false;
594+
}
595+
592596
return unserialize(self::parseScalar(substr($scalar, 12)));
593597
}
594598

@@ -599,6 +603,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
599603
return null;
600604
case 0 === strpos($scalar, '!php/const'):
601605
if (self::$constantSupport) {
606+
if (!isset($scalar[11])) {
607+
return '';
608+
}
609+
602610
$i = 0;
603611
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
604612
return \constant($const);

src/Symfony/Component/Yaml/Tests/InlineTest.php

+43
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,49 @@ public function getTestsForOctalNumbers()
738738
];
739739
}
740740

741+
/**
742+
* @dataProvider phpObjectTagWithEmptyValueProvider
743+
*/
744+
public function testPhpObjectWithEmptyValue($expected, $value)
745+
{
746+
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT));
747+
}
748+
749+
public function phpObjectTagWithEmptyValueProvider()
750+
{
751+
return [
752+
[false, '!php/object'],
753+
[false, '!php/object '],
754+
[false, '!php/object '],
755+
[[false], '[!php/object]'],
756+
[[false], '[!php/object ]'],
757+
[[false, 'foo'], '[!php/object , foo]'],
758+
];
759+
}
760+
761+
/**
762+
* @dataProvider phpConstTagWithEmptyValueProvider
763+
*/
764+
public function testPhpConstTagWithEmptyValue($expected, $value)
765+
{
766+
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT));
767+
}
768+
769+
public function phpConstTagWithEmptyValueProvider()
770+
{
771+
return [
772+
['', '!php/const'],
773+
['', '!php/const '],
774+
['', '!php/const '],
775+
[[''], '[!php/const]'],
776+
[[''], '[!php/const ]'],
777+
[['', 'foo'], '[!php/const , foo]'],
778+
[['' => 'foo'], '{!php/const: foo}'],
779+
[['' => 'foo'], '{!php/const : foo}'],
780+
[['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'],
781+
];
782+
}
783+
741784
/**
742785
* @dataProvider unquotedExclamationMarkThrowsProvider
743786
*/

0 commit comments

Comments
 (0)