Skip to content

Commit 3a14abc

Browse files
committed
Fix PHPUnit 8.5 deprecations.
1 parent e91bf2b commit 3a14abc

7 files changed

+17
-17
lines changed

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

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

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');

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');

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

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');

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');

0 commit comments

Comments
 (0)