Merge branch '5.0'
* 5.0: [Phpunit] Fix running skipped tests expecting only deprecations Fix merge [Config] dont catch instances of Error [HttpClient] fix HttpClientDataCollector when handling canceled responses [FrameworkBundle] remove mention of the old Controller class [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 symfony#28179 [DomCrawler] Skip disabled fields processing in Form
This commit is contained in:
commit
12ca64649b
2
.github/patch-types.php
vendored
2
.github/patch-types.php
vendored
@ -18,6 +18,8 @@ foreach ($loader->getClassMap() as $class => $file) {
|
||||
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
|
||||
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
|
||||
|
@ -211,6 +211,10 @@ class SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
if (!$test->getTestResultObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
|
||||
|
||||
if (isset($annotations['class']['expectedDeprecation'])) {
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PhpUnit\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* This test is meant to be skipped.
|
||||
*
|
||||
* @requires extension ext-dummy
|
||||
*/
|
||||
final class OnlyExpectingDeprecationSkippedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Do not remove this test in the next major versions.
|
||||
*
|
||||
* @group legacy
|
||||
*
|
||||
* @expectedDeprecation unreachable
|
||||
*/
|
||||
public function testExpectingOnlyDeprecations()
|
||||
{
|
||||
$this->fail('should never be ran.');
|
||||
}
|
||||
}
|
@ -51,13 +51,13 @@ class TemplateController
|
||||
$response->setMaxAge($maxAge);
|
||||
}
|
||||
|
||||
if ($sharedAge) {
|
||||
if (null !== $sharedAge) {
|
||||
$response->setSharedMaxAge($sharedAge);
|
||||
}
|
||||
|
||||
if ($private) {
|
||||
$response->setPrivate();
|
||||
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
|
||||
} elseif (false === $private || (null === $private && (null !== $maxAge || null !== $sharedAge))) {
|
||||
$response->setPublic();
|
||||
}
|
||||
|
||||
|
@ -410,8 +410,6 @@ class FrameworkExtension extends Extension
|
||||
->addTag('controller.argument_value_resolver');
|
||||
$container->registerForAutoconfiguration(AbstractController::class)
|
||||
->addTag('controller.service_arguments');
|
||||
$container->registerForAutoconfiguration('Symfony\Bundle\FrameworkBundle\Controller\Controller')
|
||||
->addTag('controller.service_arguments');
|
||||
$container->registerForAutoconfiguration(DataCollectorInterface::class)
|
||||
->addTag('data_collector');
|
||||
$container->registerForAutoconfiguration(FormTypeInterface::class)
|
||||
|
@ -94,6 +94,8 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$exists[1] = $e->getMessage();
|
||||
|
||||
throw $e;
|
||||
} finally {
|
||||
self::$autoloadedClass = $autoloadedClass;
|
||||
if (!--self::$autoloadLevel) {
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Config\Tests\Fixtures;
|
||||
|
||||
class ParseError
|
||||
{
|
||||
// missing closing bracket
|
@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Resource\ClassExistenceResource;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BadFileName;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BadParent;
|
||||
use Symfony\Component\Config\Tests\Fixtures\ParseError;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass;
|
||||
|
||||
class ClassExistenceResourceTest extends TestCase
|
||||
@ -115,4 +116,12 @@ EOF
|
||||
|
||||
$this->assertFalse($res->isFresh(0));
|
||||
}
|
||||
|
||||
public function testParseError()
|
||||
{
|
||||
$this->expectException('ParseError');
|
||||
|
||||
$res = new ClassExistenceResource(ParseError::class, false);
|
||||
$res->isFresh(0);
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ class SymfonyStyle extends OutputStyle
|
||||
{
|
||||
if (null !== $default) {
|
||||
$values = array_flip($choices);
|
||||
$default = $values[$default];
|
||||
$default = isset($values[$default]) ? $values[$default] : $default;
|
||||
}
|
||||
|
||||
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
|
||||
|
@ -1097,7 +1097,7 @@ class ContainerBuilderTest extends TestCase
|
||||
$container->set('a', new \stdClass());
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenAddServiceOnACompiledContainer()
|
||||
public function testNoExceptionWhenAddServiceOnACompiledContainer()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->compile();
|
||||
|
@ -89,10 +89,6 @@ class Form extends Link implements \ArrayAccess
|
||||
{
|
||||
$values = [];
|
||||
foreach ($this->fields->all() as $name => $field) {
|
||||
if ($field->isDisabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
|
||||
$values[$name] = $field->getValue();
|
||||
}
|
||||
@ -115,10 +111,6 @@ class Form extends Link implements \ArrayAccess
|
||||
$files = [];
|
||||
|
||||
foreach ($this->fields->all() as $name => $field) {
|
||||
if ($field->isDisabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($field instanceof Field\FileFormField) {
|
||||
$files[$name] = $field->getValue();
|
||||
}
|
||||
@ -467,7 +459,7 @@ class Form extends Link implements \ArrayAccess
|
||||
|
||||
private function addField(\DOMElement $node)
|
||||
{
|
||||
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
|
||||
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,12 +158,12 @@ class FormTest extends TestCase
|
||||
public function testMultiValuedFields()
|
||||
{
|
||||
$form = $this->createForm('<form>
|
||||
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo[]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo[4]" value="foo" />
|
||||
<input type="text" name="foo" value="foo" />
|
||||
<input type="text" name="foo[2]" value="foo" />
|
||||
<input type="text" name="foo[]" value="foo" />
|
||||
<input type="text" name="bar[foo][]" value="foo" />
|
||||
<input type="text" name="bar[foo][foobar]" value="foo" />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
');
|
||||
@ -226,10 +226,10 @@ class FormTest extends TestCase
|
||||
[],
|
||||
],
|
||||
[
|
||||
'takes into account disabled input fields',
|
||||
'skips disabled input fields',
|
||||
'<input type="text" name="foo" value="foo" disabled="disabled" />
|
||||
<input type="submit" />',
|
||||
['foo' => ['InputFormField', 'foo']],
|
||||
[],
|
||||
],
|
||||
[
|
||||
'appends the submitted button value',
|
||||
|
@ -115,7 +115,7 @@ final class HttpClientDataCollector extends DataCollector implements LateDataCol
|
||||
|
||||
unset($info['filetime'], $info['http_code'], $info['ssl_verify_result'], $info['content_type']);
|
||||
|
||||
if ($trace['method'] === $info['http_method']) {
|
||||
if (($info['http_method'] ?? null) === $trace['method']) {
|
||||
unset($info['http_method']);
|
||||
}
|
||||
|
||||
|
@ -51,9 +51,6 @@ class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
}
|
||||
}
|
||||
if (!$reason) {
|
||||
// Deprecated since Symfony 4.1. See Symfony\Component\HttpKernel\Controller\ContainerControllerResolver
|
||||
$controllers[$id.':'.$action] = $argumentRef;
|
||||
|
||||
if ('__invoke' === $action) {
|
||||
$controllers[$id] = $argumentRef;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
||||
|
||||
$controllers = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
|
||||
$this->assertSame(['c1::fooAction', 'c1:fooAction'], array_keys($controllers));
|
||||
$this->assertSame(['c1::fooAction'], array_keys($controllers));
|
||||
$this->assertSame(['bar'], array_keys($container->getDefinition((string) $controllers['c1::fooAction']->getValues()[0])->getArgument(0)));
|
||||
|
||||
$expectedLog = [
|
||||
@ -73,7 +73,7 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
||||
(new RemoveEmptyControllerArgumentLocatorsPass())->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
['invokable::__invoke', 'invokable:__invoke', 'invokable'],
|
||||
['invokable::__invoke', 'invokable'],
|
||||
array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))
|
||||
);
|
||||
}
|
||||
|
@ -589,6 +589,10 @@ class Inline
|
||||
return substr($scalar, 2);
|
||||
case 0 === strpos($scalar, '!php/object'):
|
||||
if (self::$objectSupport) {
|
||||
if (!isset($scalar[12])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return unserialize(self::parseScalar(substr($scalar, 12)));
|
||||
}
|
||||
|
||||
@ -599,6 +603,10 @@ class Inline
|
||||
return null;
|
||||
case 0 === strpos($scalar, '!php/const'):
|
||||
if (self::$constantSupport) {
|
||||
if (!isset($scalar[11])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
|
||||
return \constant($const);
|
||||
|
@ -738,6 +738,49 @@ class InlineTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider phpObjectTagWithEmptyValueProvider
|
||||
*/
|
||||
public function testPhpObjectWithEmptyValue($expected, $value)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT));
|
||||
}
|
||||
|
||||
public function phpObjectTagWithEmptyValueProvider()
|
||||
{
|
||||
return [
|
||||
[false, '!php/object'],
|
||||
[false, '!php/object '],
|
||||
[false, '!php/object '],
|
||||
[[false], '[!php/object]'],
|
||||
[[false], '[!php/object ]'],
|
||||
[[false, 'foo'], '[!php/object , foo]'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider phpConstTagWithEmptyValueProvider
|
||||
*/
|
||||
public function testPhpConstTagWithEmptyValue($expected, $value)
|
||||
{
|
||||
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT));
|
||||
}
|
||||
|
||||
public function phpConstTagWithEmptyValueProvider()
|
||||
{
|
||||
return [
|
||||
['', '!php/const'],
|
||||
['', '!php/const '],
|
||||
['', '!php/const '],
|
||||
[[''], '[!php/const]'],
|
||||
[[''], '[!php/const ]'],
|
||||
[['', 'foo'], '[!php/const , foo]'],
|
||||
[['' => 'foo'], '{!php/const: foo}'],
|
||||
[['' => 'foo'], '{!php/const : foo}'],
|
||||
[['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider unquotedExclamationMarkThrowsProvider
|
||||
*/
|
||||
|
Reference in New Issue
Block a user