Merge branch '5.1' into 5.2

* 5.1:
  Use import instead of FQCN
This commit is contained in:
Nicolas Grekas 2021-01-27 13:56:27 +01:00
commit 0e786723de
12 changed files with 31 additions and 22 deletions

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\BrowserKit\Tests;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Exception\BadMethodCallException;
use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\History;
use Symfony\Component\BrowserKit\Request; use Symfony\Component\BrowserKit\Request;
use Symfony\Component\BrowserKit\Response; use Symfony\Component\BrowserKit\Response;
@ -46,7 +47,7 @@ class AbstractBrowserTest extends TestCase
public function testGetRequestNull() public function testGetRequestNull()
{ {
$this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getRequest()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -83,7 +84,7 @@ class AbstractBrowserTest extends TestCase
public function testGetResponseNull() public function testGetResponseNull()
{ {
$this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getResponse()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getResponse()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -92,7 +93,7 @@ class AbstractBrowserTest extends TestCase
public function testGetInternalResponseNull() public function testGetInternalResponseNull()
{ {
$this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalResponse()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalResponse()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -119,7 +120,7 @@ class AbstractBrowserTest extends TestCase
public function testGetCrawlerNull() public function testGetCrawlerNull()
{ {
$this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getCrawler()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getCrawler()".');
$client = $this->getBrowser(); $client = $this->getBrowser();
@ -832,7 +833,7 @@ class AbstractBrowserTest extends TestCase
public function testInternalRequestNull() public function testInternalRequestNull()
{ {
$this->expectException(\Symfony\Component\BrowserKit\Exception\BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalRequest()".'); $this->expectExceptionMessage('The "request()" method must be called before "Symfony\\Component\\BrowserKit\\AbstractBrowser::getInternalRequest()".');
$client = $this->getBrowser(); $client = $this->getBrowser();

View File

@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPa
use Symfony\Component\DependencyInjection\Compiler\RegisterEnvVarProcessorsPass; use Symfony\Component\DependencyInjection\Compiler\RegisterEnvVarProcessorsPass;
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass; use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Extension\Extension;
class ValidateEnvPlaceholdersPassTest extends TestCase class ValidateEnvPlaceholdersPassTest extends TestCase
@ -59,7 +60,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
public function testDefaultEnvWithoutPrefixIsValidatedInConfig() public function testDefaultEnvWithoutPrefixIsValidatedInConfig()
{ {
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "float" given to "env(FLOATISH)".'); $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "float" given to "env(FLOATISH)".');
$container = new ContainerBuilder(); $container = new ContainerBuilder();
@ -219,7 +220,7 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation() public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation()
{ {
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('The path "env_extension.scalar_node_not_empty_validated" cannot contain an environment variable when empty values are not allowed by definition and are validated.'); $this->expectExceptionMessage('The path "env_extension.scalar_node_not_empty_validated" cannot contain an environment variable when empty values are not allowed by definition and are validated.');
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Extension;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\InvalidConfig\InvalidConfigExtension; use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\InvalidConfig\InvalidConfigExtension;
use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\SemiValidConfig\SemiValidConfigExtension; use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\SemiValidConfig\SemiValidConfigExtension;
@ -71,7 +72,7 @@ class ExtensionTest extends TestCase
public function testInvalidConfiguration() public function testInvalidConfiguration()
{ {
$this->expectException(\Symfony\Component\DependencyInjection\Exception\LogicException::class); $this->expectException(LogicException::class);
$this->expectExceptionMessage('The extension configuration class "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Extension\\InvalidConfig\\Configuration" must implement "Symfony\\Component\\Config\\Definition\\ConfigurationInterface".'); $this->expectExceptionMessage('The extension configuration class "Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Extension\\InvalidConfig\\Configuration" must implement "Symfony\\Component\\Config\\Definition\\ConfigurationInterface".');
$extension = new InvalidConfigExtension(); $extension = new InvalidConfigExtension();

View File

@ -113,7 +113,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testResolveEnvRequiresStrings() public function testResolveEnvRequiresStrings()
{ {
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "int" given.'); $this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "int" given.');
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();
@ -124,7 +124,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testGetDefaultScalarEnv() public function testGetDefaultScalarEnv()
{ {
$this->expectException(\Symfony\Component\DependencyInjection\Exception\RuntimeException::class); $this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "int" given to "env(INT_VAR)".'); $this->expectExceptionMessage('The default value of an env() parameter must be a string or null, but "int" given to "env(INT_VAR)".');
$bag = new EnvPlaceholderParameterBag(); $bag = new EnvPlaceholderParameterBag();

View File

@ -350,7 +350,7 @@ class FormTypeTest extends BaseTypeTest
public function testActionCannotBeNull() public function testActionCannotBeNull()
{ {
$this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); $this->expectException(InvalidOptionsException::class);
$this->factory->create(static::TESTED_TYPE, null, ['action' => null]); $this->factory->create(static::TESTED_TYPE, null, ['action' => null]);
} }

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\Type; namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Intl\Util\IntlTestHelper;
class NumberTypeTest extends BaseTypeTest class NumberTypeTest extends BaseTypeTest
@ -80,7 +81,7 @@ class NumberTypeTest extends BaseTypeTest
public function testStringInputWithFloatData() public function testStringInputWithFloatData()
{ {
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectException(TransformationFailedException::class);
$this->expectExceptionMessage('Expected a numeric string.'); $this->expectExceptionMessage('Expected a numeric string.');
$this->factory->create(static::TESTED_TYPE, 12345.6789, [ $this->factory->create(static::TESTED_TYPE, 12345.6789, [
@ -91,7 +92,7 @@ class NumberTypeTest extends BaseTypeTest
public function testStringInputWithIntData() public function testStringInputWithIntData()
{ {
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class); $this->expectException(TransformationFailedException::class);
$this->expectExceptionMessage('Expected a numeric string.'); $this->expectExceptionMessage('Expected a numeric string.');
$this->factory->create(static::TESTED_TYPE, 12345, [ $this->factory->create(static::TESTED_TYPE, 12345, [

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Exception\InvalidConfigurationException; use Symfony\Component\Form\Exception\InvalidConfigurationException;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
@ -478,7 +479,7 @@ class TimeTypeTest extends BaseTypeTest
public function testSetDataDifferentTimezonesWithoutReferenceDate() public function testSetDataDifferentTimezonesWithoutReferenceDate()
{ {
$this->expectException(\Symfony\Component\Form\Exception\LogicException::class); $this->expectException(LogicException::class);
$this->expectExceptionMessage('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.'); $this->expectExceptionMessage('Using different values for the "model_timezone" and "view_timezone" options without configuring a reference date is not supported.');
$form = $this->factory->create(static::TESTED_TYPE, null, [ $form = $this->factory->create(static::TESTED_TYPE, null, [

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests; namespace Symfony\Component\Form\Tests;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormRendererEngineInterface; use Symfony\Component\Form\FormRendererEngineInterface;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
@ -32,7 +33,7 @@ class FormRendererTest extends TestCase
public function testRenderARenderedField() public function testRenderARenderedField()
{ {
$this->expectException(\Symfony\Component\Form\Exception\BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead.'); $this->expectExceptionMessage('Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead.');
$formView = new FormView(); $formView = new FormView();

View File

@ -2404,7 +2404,7 @@ class OptionsResolverTest extends TestCase
public function testFailsIfOptionIsAlreadyDefined() public function testFailsIfOptionIsAlreadyDefined()
{ {
$this->expectException(\Symfony\Component\OptionsResolver\Exception\OptionDefinitionException::class); $this->expectException(OptionDefinitionException::class);
$this->expectExceptionMessage('The option "foo" is already defined.'); $this->expectExceptionMessage('The option "foo" is already defined.');
$this->resolver->define('foo'); $this->resolver->define('foo');
$this->resolver->define('foo'); $this->resolver->define('foo');

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider; use Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\Exception\BadCredentialsException;
@ -30,7 +31,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
$this->assertTrue($provider->supports($this->getSupportedToken())); $this->assertTrue($provider->supports($this->getSupportedToken()));
$this->assertFalse($provider->supports($this->createMock(TokenInterface::class))); $this->assertFalse($provider->supports($this->createMock(TokenInterface::class)));
$token = $this->createMock(\Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::class); $token = $this->createMock(PreAuthenticatedToken::class);
$token $token
->expects($this->once()) ->expects($this->once())
->method('getFirewallName') ->method('getFirewallName')
@ -66,7 +67,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
$provider = $this->getProvider($user); $provider = $this->getProvider($user);
$token = $provider->authenticate($this->getSupportedToken('fabien', 'pass')); $token = $provider->authenticate($this->getSupportedToken('fabien', 'pass'));
$this->assertInstanceOf(\Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::class, $token); $this->assertInstanceOf(PreAuthenticatedToken::class, $token);
$this->assertEquals('pass', $token->getCredentials()); $this->assertEquals('pass', $token->getCredentials());
$this->assertEquals('key', $token->getFirewallName()); $this->assertEquals('key', $token->getFirewallName());
$this->assertEquals([], $token->getRoleNames()); $this->assertEquals([], $token->getRoleNames());
@ -92,7 +93,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
protected function getSupportedToken($user = false, $credentials = false) protected function getSupportedToken($user = false, $credentials = false)
{ {
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::class)->setMethods(['getUser', 'getCredentials', 'getFirewallName'])->disableOriginalConstructor()->getMock(); $token = $this->getMockBuilder(PreAuthenticatedToken::class)->setMethods(['getUser', 'getCredentials', 'getFirewallName'])->disableOriginalConstructor()->getMock();
if (false !== $user) { if (false !== $user) {
$token->expects($this->once()) $token->expects($this->once())
->method('getUser') ->method('getUser')

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\Validator\Tests\Constraints;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraints\AtLeastOneOf; use Symfony\Component\Validator\Constraints\AtLeastOneOf;
use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
/** /**
* @author Przemysław Bogusz <przemyslaw.bogusz@tubotax.pl> * @author Przemysław Bogusz <przemyslaw.bogusz@tubotax.pl>
@ -22,7 +23,7 @@ class AtLeastOneOfTest extends TestCase
{ {
public function testRejectNonConstraints() public function testRejectNonConstraints()
{ {
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectException(ConstraintDefinitionException::class);
new AtLeastOneOf([ new AtLeastOneOf([
'foo', 'foo',
]); ]);
@ -30,7 +31,7 @@ class AtLeastOneOfTest extends TestCase
public function testRejectValidConstraint() public function testRejectValidConstraint()
{ {
$this->expectException(\Symfony\Component\Validator\Exception\ConstraintDefinitionException::class); $this->expectException(ConstraintDefinitionException::class);
new AtLeastOneOf([ new AtLeastOneOf([
new Valid(), new Valid(),
]); ]);

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\Validator\Tests\Constraints;
use Symfony\Component\Validator\Constraints\Hostname; use Symfony\Component\Validator\Constraints\Hostname;
use Symfony\Component\Validator\Constraints\HostnameValidator; use Symfony\Component\Validator\Constraints\HostnameValidator;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/** /**
@ -36,7 +37,7 @@ class HostnameValidatorTest extends ConstraintValidatorTestCase
public function testExpectsStringCompatibleType() public function testExpectsStringCompatibleType()
{ {
$this->expectException(\Symfony\Component\Validator\Exception\UnexpectedValueException::class); $this->expectException(UnexpectedValueException::class);
$this->validator->validate(new \stdClass(), new Hostname()); $this->validator->validate(new \stdClass(), new Hostname());
} }