Skip to content

Commit 2e02a27

Browse files
bug #36408 [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions (soyuka)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | na | License | MIT | Doc PR | na expectExceptionMessageRegExp is deprecated coming phpunit 8.5.3 see sebastianbergmann/phpunit#4133 Not sure if I need to add something else lmk. Commits ------- cfd5a29eaf [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions
2 parents 8ff02d3 + 2ed631d commit 2e02a27

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);
@@ -395,15 +395,15 @@ public function testLoadYamlOnlyWithKeys()
395395
public function testTagWithEmptyNameThrowsException()
396396
{
397397
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
398-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
398+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
399399
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
400400
$loader->load('tag_name_empty_string.yml');
401401
}
402402

403403
public function testTagWithNonStringNameThrowsException()
404404
{
405405
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
406-
$this->expectExceptionMessageRegExp('/The tag name for service ".+" in .+ must be a non-empty string/');
406+
$this->expectExceptionMessageMatches('/The tag name for service ".+" in .+ must be a non-empty string/');
407407
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
408408
$loader->load('tag_name_no_string.yml');
409409
}
@@ -504,7 +504,7 @@ public function testPrototypeWithNamespace()
504504
public function testPrototypeWithNamespaceAndNoResource()
505505
{
506506
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
507-
$this->expectExceptionMessageRegExp('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
507+
$this->expectExceptionMessageMatches('/A "resource" attribute must be set when the "namespace" attribute is set for service ".+" in .+/');
508508
$container = new ContainerBuilder();
509509
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
510510
$loader->load('services_prototype_namespace_without_resource.yml');
@@ -632,7 +632,7 @@ public function testDecoratedServicesWithWrongOnInvalidSyntaxThrowsException()
632632
public function testInvalidTagsWithDefaults()
633633
{
634634
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
635-
$this->expectExceptionMessageRegExp('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
635+
$this->expectExceptionMessageMatches('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./');
636636
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
637637
$loader->load('services31_invalid_tags.yml');
638638
}
@@ -722,7 +722,7 @@ public function testAnonymousServicesInInstanceof()
722722
public function testAnonymousServicesWithAliases()
723723
{
724724
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
725-
$this->expectExceptionMessageRegExp('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
725+
$this->expectExceptionMessageMatches('/Creating an alias using the tag "!service" is not allowed in ".+anonymous_services_alias\.yml"\./');
726726
$container = new ContainerBuilder();
727727
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
728728
$loader->load('anonymous_services_alias.yml');
@@ -731,7 +731,7 @@ public function testAnonymousServicesWithAliases()
731731
public function testAnonymousServicesInParameters()
732732
{
733733
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
734-
$this->expectExceptionMessageRegExp('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
734+
$this->expectExceptionMessageMatches('/Using an anonymous service in a parameter is not allowed in ".+anonymous_services_in_parameters\.yml"\./');
735735
$container = new ContainerBuilder();
736736
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
737737
$loader->load('anonymous_services_in_parameters.yml');
@@ -750,7 +750,7 @@ public function testAutoConfigureInstanceof()
750750
public function testEmptyDefaultsThrowsClearException()
751751
{
752752
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
753-
$this->expectExceptionMessageRegExp('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./');
753+
$this->expectExceptionMessageMatches('/Service "_defaults" key must be an array, "NULL" given in ".+bad_empty_defaults\.yml"\./');
754754
$container = new ContainerBuilder();
755755
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
756756
$loader->load('bad_empty_defaults.yml');
@@ -759,7 +759,7 @@ public function testEmptyDefaultsThrowsClearException()
759759
public function testEmptyInstanceofThrowsClearException()
760760
{
761761
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
762-
$this->expectExceptionMessageRegExp('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./');
762+
$this->expectExceptionMessageMatches('/Service "_instanceof" key must be an array, "NULL" given in ".+bad_empty_instanceof\.yml"\./');
763763
$container = new ContainerBuilder();
764764
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
765765
$loader->load('bad_empty_instanceof.yml');
@@ -768,7 +768,7 @@ public function testEmptyInstanceofThrowsClearException()
768768
public function testUnsupportedKeywordThrowsException()
769769
{
770770
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
771-
$this->expectExceptionMessageRegExp('/^The configuration key "private" is unsupported for definition "bar"/');
771+
$this->expectExceptionMessageMatches('/^The configuration key "private" is unsupported for definition "bar"/');
772772
$container = new ContainerBuilder();
773773
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
774774
$loader->load('bad_keyword.yml');
@@ -777,7 +777,7 @@ public function testUnsupportedKeywordThrowsException()
777777
public function testUnsupportedKeywordInServiceAliasThrowsException()
778778
{
779779
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
780-
$this->expectExceptionMessageRegExp('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/');
780+
$this->expectExceptionMessageMatches('/^The configuration key "calls" is unsupported for the service "bar" which is defined as an alias/');
781781
$container = new ContainerBuilder();
782782
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
783783
$loader->load('bad_alias.yml');

0 commit comments

Comments
 (0)