Skip to content

Commit 2ed631d

Browse files
soyukanicolas-grekas
authored andcommitted
[PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions
1 parent 755b188 commit 2ed631d

6 files changed

+17
-17
lines changed

Tests/Compiler/ResolveChildDefinitionsPassTest.php

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

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

Tests/Compiler/ResolveInstanceofConditionalsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function testProcessForAutoconfiguredCalls()
233233
public function testProcessThrowsExceptionForArguments()
234234
{
235235
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
236-
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
236+
$this->expectExceptionMessageMatches('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
237237
$container = new ContainerBuilder();
238238
$container->registerForAutoconfiguration(parent::class)
239239
->addArgument('bar');

Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testInvalidEnvInConfig()
105105
public function testNulledEnvInConfig()
106106
{
107107
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidTypeException');
108-
$this->expectExceptionMessageRegexp('/^Invalid type for path "env_extension\.int_node"\. Expected "?int"?, but got (NULL|"null")\.$/');
108+
$this->expectExceptionMessageMatches('/^Invalid type for path "env_extension\.int_node"\. Expected "?int"?, but got (NULL|"null")\.$/');
109109
$container = new ContainerBuilder();
110110
$container->setParameter('env(NULLED)', null);
111111
$container->registerExtension(new EnvExtension());

Tests/Loader/FileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function testMissingParentClass()
216216
public function testRegisterClassesWithBadPrefix()
217217
{
218218
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
219-
$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/');
219+
$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/');
220220
$container = new ContainerBuilder();
221221
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
222222

Tests/Loader/XmlFileLoaderTest.php

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

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function setUpBeforeClass(): void
5050
public function testLoadUnExistFile()
5151
{
5252
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
53-
$this->expectExceptionMessageRegExp('/The file ".+" does not exist./');
53+
$this->expectExceptionMessageMatches('/The file ".+" does not exist./');
5454
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/ini'));
5555
$r = new \ReflectionObject($loader);
5656
$m = $r->getMethod('loadFile');
@@ -62,7 +62,7 @@ public function testLoadUnExistFile()
6262
public function testLoadInvalidYamlFile()
6363
{
6464
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
65-
$this->expectExceptionMessageRegExp('/The file ".+" does not contain valid YAML./');
65+
$this->expectExceptionMessageMatches('/The file ".+" does not contain valid YAML./');
6666
$path = self::$fixturesPath.'/ini';
6767
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator($path));
6868
$r = new \ReflectionObject($loader);
@@ -384,15 +384,15 @@ public function testLoadYamlOnlyWithKeys()
384384
public function testTagWithEmptyNameThrowsException()
385385
{
386386
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
387-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
387+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
388388
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
389389
$loader->load('tag_name_empty_string.yml');
390390
}
391391

392392
public function testTagWithNonStringNameThrowsException()
393393
{
394394
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
395-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
395+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
396396
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
397397
$loader->load('tag_name_no_string.yml');
398398
}
@@ -493,7 +493,7 @@ public function testPrototypeWithNamespace()
493493
public function testPrototypeWithNamespaceAndNoResource()
494494
{
495495
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
496-
$this->expectExceptionMessageRegExp('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
496+
$this->expectExceptionMessageMatches('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
497497
$container = new ContainerBuilder();
498498
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
499499
$loader->load('services_prototype_namespace_without_resource.yml');
@@ -621,7 +621,7 @@ public function testDecoratedServicesWithWrongOnInvalidSyntaxThrowsException()
621621
public function testInvalidTagsWithDefaults()
622622
{
623623
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
624-
$this->expectExceptionMessageRegExp('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
624+
$this->expectExceptionMessageMatches('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
625625
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
626626
$loader->load('services31_invalid_tags.yml');
627627
}
@@ -711,7 +711,7 @@ public function testAnonymousServicesInInstanceof()
711711
public function testAnonymousServicesWithAliases()
712712
{
713713
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
714-
$this->expectExceptionMessageRegExp('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
714+
$this->expectExceptionMessageMatches('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
715715
$container = new ContainerBuilder();
716716
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
717717
$loader->load('anonymous_services_alias.yml');
@@ -720,7 +720,7 @@ public function testAnonymousServicesWithAliases()
720720
public function testAnonymousServicesInParameters()
721721
{
722722
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
723-
$this->expectExceptionMessageRegExp('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
723+
$this->expectExceptionMessageMatches('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
724724
$container = new ContainerBuilder();
725725
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
726726
$loader->load('anonymous_services_in_parameters.yml');
@@ -739,7 +739,7 @@ public function testAutoConfigureInstanceof()
739739
public function testEmptyDefaultsThrowsClearException()
740740
{
741741
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
742-
$this->expectExceptionMessageRegExp('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./');
742+
$this->expectExceptionMessageMatches('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./');
743743
$container = new ContainerBuilder();
744744
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
745745
$loader->load('bad_empty_defaults.yml');
@@ -748,7 +748,7 @@ public function testEmptyDefaultsThrowsClearException()
748748
public function testEmptyInstanceofThrowsClearException()
749749
{
750750
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
751-
$this->expectExceptionMessageRegExp('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./');
751+
$this->expectExceptionMessageMatches('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./');
752752
$container = new ContainerBuilder();
753753
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
754754
$loader->load('bad_empty_instanceof.yml');
@@ -757,7 +757,7 @@ public function testEmptyInstanceofThrowsClearException()
757757
public function testUnsupportedKeywordThrowsException()
758758
{
759759
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
760-
$this->expectExceptionMessageRegExp('/^The configuration key "private" is unsupported for definition "bar"/');
760+
$this->expectExceptionMessageMatches('/^The configuration key "private" is unsupported for definition "bar"/');
761761
$container = new ContainerBuilder();
762762
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
763763
$loader->load('bad_keyword.yml');
@@ -766,7 +766,7 @@ public function testUnsupportedKeywordThrowsException()
766766
public function testUnsupportedKeywordInServiceAliasThrowsException()
767767
{
768768
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
769-
$this->expectExceptionMessageRegExp('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/');
769+
$this->expectExceptionMessageMatches('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/');
770770
$container = new ContainerBuilder();
771771
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
772772
$loader->load('bad_alias.yml');

0 commit comments

Comments
 (0)