8000 Fix PHPUnit 8.5 deprecations. · symfony/symfony@ec525e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec525e6

Browse files
committed
Fix PHPUnit 8.5 deprecations.
1 parent 65fc07a commit ec525e6

File tree

19 files changed

+40
-36
lines changed

19 files changed

+40
-36
lines changed

src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testTwigErrorIfLocatorReturnsFalse()
9898
public function testTwigErrorIfTemplateDoesNotExist()
9999
{
100100
$this->expectException('Twig\Error\LoaderError');
101-
$this->expectExceptionMessageRegExp('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.Resources.views\)/');
101+
$this->expectExceptionMessageMatches('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..Dependen F438 cyInjection.Fixtures.Resources.views\)/');
102102
$parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
103103
$locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
104104

src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testGetPattern()
6666
public function testResourceDoesNotExist()
6767
{
6868
$this->expectException('InvalidArgumentException');
69-
$this->expectExceptionMessageRegExp('/The directory ".*" does not exist./');
69+
$this->expectExceptionMessageMatches('/The directory ".*" does not exist./');
7070
new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
7171
}
7272

src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testToString()
5656
public function testResourceDoesNotExist()
5757
{
5858
$this->expectException('InvalidArgumentException');
59-
$this->expectExceptionMessageRegExp('/The file ".*" does not exist./');
59+
$this->expectExceptionMessageMatches('/The file ".*" does not exist./');
6060
new FileResource('/____foo/foobar'.mt_rand(1, 999999));
6161
}
6262

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public function testClassNotFoundThrowsException()
434434
public function testParentClassNotFoundThrowsException()
435435
{
436436
$this->expectException('Symfony\Component\DependencyInjection\Exception\AutowiringFailedException');
437-
$this->expectExceptionMessageRegExp('{^Cannot autowire service "a": argument "\$r" of method "(Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Compiler\\\\)BadParentTypeHintedArgument::__construct\(\)" has type "\1OptionalServiceClass" but this class is missing a parent class \(Class "?Symfony\\\\Bug\\\\NotExistClass"? not found}');
437+
$this->expectExceptionMessageMatches('{^Cannot autowire service "a": argument "\$r" of method "(Symfony\\\\Component\\\\DependencyInjection\\\\Tests\\\\Compiler\\\\)BadParentTypeHintedArgument::__construct\(\)" has type "\1OptionalServiceClass" but this class is missing a parent class \(Class "?Symfony\\\\Bug\\\\NotExistClass"? not found}');
438438

439439
$container = new ContainerBuilder();
440440

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testUnusedBinding()
6565
public function testMissingParent()
6666
{
6767
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
68-
$this->expectExceptionMessageRegExp('/Unused binding "\$quz" in service [\s\S]+/');
68+
$this->expectExceptionMessageMatches('/Unused binding "\$quz" in service [\s\S]+/');
6969

7070
$container = new ContainerBuilder();
7171

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ protected function process(ContainerBuilder $container)
435435
public function testProcessDetectsChildDefinitionIndirectCircularReference()
436436
{
437437
$this->expectException('Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException');
438-
$this->expectExceptionMessageRegExp('/^Circular reference detected for service "c", path: "c -> b -> a -> c"./');
438+
$this->expectExceptionMessageMatches('/^Circular reference detected for service "c", path: "c -> b -> a -> c"./');
439439
$container = new ContainerBuilder();
440440

441441
$container->register('a');

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function testBadInterfaceForAutomaticInstanceofIsOk()
201201
public function testProcessThrowsExceptionForAutoconfiguredCalls()
202202
{
203203
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
204-
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines method calls but these are not supported and should be removed\./');
204+
$this->expectExceptionMessageMatches('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines method calls but these are not supported and should be removed\./');
205205
$container = new ContainerBuilder();
206206
$container->registerForAutoconfiguration(parent::class)
207207
->addMethodCall('setFoo');
@@ -212,7 +212,7 @@ public function testProcessThrowsExceptionForAutoconfiguredCalls()
212212
public function testProcessThrowsExceptionForArguments()
213213
{
214214
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
215-
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
215+
$this->expectExceptionMessageMatches('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
216216
$container = new ContainerBuilder();
217217
$container->registerForAutoconfiguration(parent::class)
218218
->addArgument('bar');

src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function testMissingParentClass()
194194
public function testRegisterClassesWithBadPrefix()
195195
{
196196
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
197-
$this->expectExceptionMessageRegExp('/Expected to find class "Symfony\\\Component\\\DependencyInjection\\\Tests\\\Fixtures\\\Prototype\\\Bar" in file ".+" while importing services from resource "Prototype\/Sub\/\*", but it was not found\! Check the namespace prefix used with the resource/');
197+
$this->expectExceptionMessageMatches('/Expected to find class "Symfony\\\Component\\\DependencyInjection\\\Tests\\\Fixtures\\\Prototype\\\Bar" in file ".+" while importing services from resource "Prototype\/Sub\/\*", but it was not found\! Check the namespace prefix used with the resource/');
198198
$container = new ContainerBuilder();
199199
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
200200

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function testParseTagsWithoutNameThrowsException()
336336
public function testParseTagWithEmptyNameThrowsException()
337337
{
338338
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
339-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .* must be a non-empty string/');
339+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .* must be a non-empty string/');
340340
$container = new ContainerBuilder();
341341
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
342342
$loader->load('tag_with_empty_name.xml');

src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function setUpBeforeClass()
4545
public function testLoadUnExistFile()
4646
{
4747
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
48-
$this->expectExceptionMessageRegExp('/The file ".+" does not exist./');
48+
$this->expectExceptionMessageMatches('/The file ".+" does not exist./');
4949
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
5050
$r = new \ReflectionObject($loader);
5151
$m = $r->getMethod('loadFile');
@@ -57,7 +57,7 @@ public function testLoadUnExistFile()
5757
public function testLoadInvalidYamlFile()
5858
{
5959
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
60-
$this->expectExceptionMessageRegExp('/The file ".+" does not contain valid YAML./');
60+
$this->expectExceptionMessageMatches('/The file ".+" does not contain valid YAML./');
6161
$path = self::$fixturesPath.'/ini';
6262
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path));
6363
$r = new \ReflectionObject($loader);
@@ -300,15 +300,15 @@ public function testLoadYamlOnlyWithKeys()
300300
public function testTagWithEmptyNameThrowsException()
301301
{
302302
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
303-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
303+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
304304
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
305305
$loader->load('tag_name_empty_string.yml');
306306
}
307307

308308
public function testTagWithNonStringNameThrowsException()
309309
{
310310
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
311-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
311+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
312312
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
313313
$loader->load('tag_name_no_string.yml');
314314
}
@@ -424,7 +424,7 @@ public function testPrototypeWithNamespace()
424424
public function testPrototypeWithNamespaceAndNoResource()
425425
{
426426
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
427-
$this->expectExceptionMessageRegExp('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
427+
$this->expectExceptionMessageMatches('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
428428
$container = new ContainerBuilder();
429429
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
430430
$loader->load('services_prototype_namespace_without_resource.yml');
@@ -536,7 +536,7 @@ public function testDecoratedServicesWithWrongSyntaxThrowsException()
536536
public function testInvalidTagsWithDefaults()
537537
{
538538
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
539-
$this->expectExceptionMessageRegExp('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
539+
$this->expectExceptionMessageMatches('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
540540
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
541541
$loader->load('services31_invalid_tags.yml');
542542
}
@@ -628,7 +628,7 @@ public function testAnonymousServicesInInstanceof()
628628
public function testAnonymousServicesWithAliases()
629629
{
630630
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
631-
$this->expectExceptionMessageRegExp('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
631+
$this->expectExceptionMessageMatches('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
632632
$container = new ContainerBuilder();
633633
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
634634
$loader->load('anonymous_services_alias.yml');
@@ -637,7 +637,7 @@ public function testAnonymousServicesWithAliases()
637637
public function testAnonymousServicesInParameters()
638638
{
639639
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
640-
$this->expectExceptionMessageRegExp('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
640+
$this->expectExceptionMessageMatches('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
641641
$container = new ContainerBuilder();
642642
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
643643
$loader->load('anonymous_services_in_parameters.yml');
@@ -656,7 +656,7 @@ public function testAutoConfigureInstanceof()
656656
public function testEmptyDefaultsThrowsClearException()
657657
{
658658
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
659-
$this->expectExceptionMessageRegExp('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./');
659+
$this->expectExceptionMessageMatches('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./');
660660
$container = new ContainerBuilder();
661661
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
662662
$loader->load('bad_empty_defaults.yml');
@@ -665,7 +665,7 @@ public function testEmptyDefaultsThrowsClearException()
665665
public function testEmptyInstanceofThrowsClearException()
666666
{
667667
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
668-
$this->expectExceptionMessageRegExp('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./');
668+
$this->expectExceptionMessageMatches('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./');
669669
$container = new ContainerBuilder();
670670
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
671671
$loader->load('bad_empty_instanceof.yml');

src/Symfony/Component/ExpressionLanguage/Tests/ExpressionLanguageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function testRegisterAfterEval($registerCallback)
269269
public function testCallBadCallable()
270270
{
271271
$this->expectException('RuntimeException');
272-
$this->expectExceptionMessageRegExp('/Unable to call method "\w+" of object "\w+"./');
272+
$this->expectExceptionMessageMatches('/Unable to call method "\w+" of object "\w+"./');
273273
$el = new ExpressionLanguage();
274274
$el->evaluate('foo.myfunction()', ['foo' => new \stdClass()]);
275275
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function testGc()
127127
*/
128128
public function testValidateId()
129129
{
130-
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
130+
$mock = $this->getMockBuilder(TestSessionHandler::class)->getMock();
131131
$mock->expects($this->once())
132132
->method('validateId');
133133

@@ -142,7 +142,7 @@ public function testValidateId()
142142
*/
143143
public function testUpdateTimestamp()
144144
{
145-
$mock = $this->getMockBuilder(['SessionHandlerInterface', 'SessionUpdateTimestampHandlerInterface'])->getMock();
145+
$mock = $this->getMockBuilder(TestSessionHandler::class)->getMock();
146146
$mock->expects($this->once())
147147
->method('updateTimestamp')
148148
->willReturn(false);
@@ -156,3 +156,7 @@ public function testUpdateTimestamp()
156156
$this->proxy->updateTimestamp('id', 'data');
157157
}
158158
}
159+
160+
abstract class TestSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
161+
{
162+
}

src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function testGetControllerOnNonUndefinedFunction($controller, $exceptionN
232232
// All this logic needs to be duplicated, since calling parent::testGetControllerOnNonUndefinedFunction will override the expected exception and not use the regex
233233
$resolver = $this->createControllerResolver();
234234
$this->expectException($exceptionName);
235-
$this->expectExceptionMessageRegExp($exceptionMessage);
235+
$this->expectExceptionMessageMatches($exceptionMessage);
236236

237237
$request = Request::create('/');
238238
$request->attributes->set('_controller', $controller);

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections()
149149
public function testSetValueFailsIfNoAdderNorRemoverFound()
150150
{
151151
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
152-
$this->expectExceptionMessageRegExp('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./');
152+
$this->expectExceptionMessageMatches('/Could not determine access type for property "axes" in class "Mock_PropertyAccessorCollectionTest_CarNoAdderAndRemover_[^"]*"./');
153153
$car = $this->getMockBuilder(__CLASS__.'_CarNoAdderAndRemover')->getMock();
154154
$axesBefore = $this->getContainer([1 => 'second', 3 => 'fourth']);
155155
$axesAfter = $this->getContainer([0 => 'first', 1 => 'second', 2 => 'third']);

src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function testLoadRouteWithControllerSetInDefaults()
339339
public function testOverrideControllerInDefaults()
340340
{
341341
$this->expectException('InvalidArgumentException');
342-
$this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for "app_blog"/');
342+
$this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both F438 the "controller" attribute and the defaults key "_controller" for "app_blog"/');
343343
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
344344
$loader->load('override_defaults.xml');
345345
}
@@ -371,7 +371,7 @@ public function provideFilesImportingRoutesWithControllers()
371371
public function testImportWithOverriddenController()
372372
{
373373
$this->expectException('InvalidArgumentException');
374-
$this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/');
374+
$this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/');
375375
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
376376
$loader->load('import_override_defaults.xml');
377377
}

src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testLoadRouteWithControllerSetInDefaults()
142142
public function testOverrideControllerInDefaults()
143143
{
144144
$this->expectException('InvalidArgumentException');
145-
$this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/');
145+
$this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/');
146146
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
147147
$loader->load('override_defaults.yml');
148148
}
@@ -174,7 +174,7 @@ public function provideFilesImportingRoutesWithControllers()
174174
public function testImportWithOverriddenController()
175175
{
176176
$this->expectException('InvalidArgumentException');
177-
$this->expectExceptionMessageRegExp('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/');
177+
$this->expectExceptionMessageMatches('/The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/');
178178
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/controller']));
179179
$loader->load('import_override_defaults.yml');
180180
}

src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function testSupportsChecksGuardAuthenticatorsTokenOrigin()
216216
public function testAuthenticateFailsOnNonOriginatingToken()
217217
{
218218
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
219-
$this->expectExceptionMessageRegExp('/second_firewall_0/');
219+
$this->expectExceptionMessageMatches('/second_firewall_0/');
220220
$authenticatorA = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
221221
$authenticators = [$authenticatorA];
222222

0 commit comments

Comments
 (0)
0