Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnits expectExceptionMessageRegExp becomes deprecated in Phpunit 9 #3626

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -452,7 +452,7 @@ public function testAddResourceClassDirectories()
public function testResourcesToWatchWithUnsupportedMappingType()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessageRegExp('/Unsupported mapping type in ".+", supported types are XML & YAML\\./');
$this->expectExceptionMessageMatches('/Unsupported mapping type in ".+", supported types are XML & YAML\\./');

$config = self::DEFAULT_CONFIG;
$config['api_platform']['mapping']['paths'] = [__FILE__];
Expand Down
Expand Up @@ -261,7 +261,7 @@ public function invalidHttpStatusCodeProvider()
public function testExceptionToStatusConfigWithInvalidHttpStatusCode($invalidHttpStatusCode)
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessageRegExp('/The HTTP status code ".+" is not valid\\./');
$this->expectExceptionMessageMatches('/The HTTP status code ".+" is not valid\\./');

$this->processor->processConfiguration($this->configuration, [
'api_platform' => [
Expand Down Expand Up @@ -290,7 +290,7 @@ public function invalidHttpStatusCodeValueProvider()
public function testExceptionToStatusConfigWithInvalidHttpStatusCodeValue($invalidHttpStatusCodeValue)
{
$this->expectException(InvalidTypeException::class);
$this->expectExceptionMessageRegExp('/Invalid type for path "api_platform\\.exception_to_status\\.Exception". Expected "?int"?, but got "?.+"?\./');
$this->expectExceptionMessageMatches('/Invalid type for path "api_platform\\.exception_to_status\\.Exception". Expected "?int"?, but got "?.+"?\./');

$this->processor->processConfiguration($this->configuration, [
'api_platform' => [
Expand Down Expand Up @@ -369,7 +369,7 @@ public function testSwaggerVersionConfig()
$this->assertSame([2], $config['swagger']['versions']);

$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessageRegExp('/Only the versions .+ are supported. Got .+./');
$this->expectExceptionMessageMatches('/Only the versions .+ are supported. Got .+./');

$this->processor->processConfiguration($this->configuration, [
'api_platform' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/GraphQl/Type/Definition/IterableTypeTest.php
Expand Up @@ -43,7 +43,7 @@ public function testSerialize()
$iterableType = new IterableType();

$this->expectException(Error::class);
$this->expectExceptionMessageRegExp('/`Iterable` cannot represent non iterable value: .+/');
$this->expectExceptionMessageMatches('/`Iterable` cannot represent non iterable value: .+/');

$iterableType->serialize('foo');

Expand All @@ -55,7 +55,7 @@ public function testParseValue()
$iterableType = new IterableType();

$this->expectException(Error::class);
$this->expectExceptionMessageRegExp('/`Iterable` cannot represent non iterable value: .+/');
$this->expectExceptionMessageMatches('/`Iterable` cannot represent non iterable value: .+/');

$iterableType->parseValue('foo');

Expand Down
2 changes: 1 addition & 1 deletion tests/Metadata/Extractor/YamlExtractorTestCase.php
Expand Up @@ -34,7 +34,7 @@ public function testInvalidProperty()
public function testParseException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/Unable to parse in ".+\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/parse_exception.yml"/');
$this->expectExceptionMessageMatches('/Unable to parse in ".+\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/parse_exception.yml"/');

(new YamlExtractor([__DIR__.'/../../Fixtures/FileConfigurations/parse_exception.yml']))->getResources();
}
Expand Down
Expand Up @@ -87,7 +87,7 @@ public function testCreateWithNonexistentPropertyXml()
public function testCreateWithInvalidXml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('#.+Element \'\\{https://api-platform.com/schema/metadata\\}foo\': This element is not expected\\..+#');
$this->expectExceptionMessageMatches('#.+Element \'\\{https://api-platform.com/schema/metadata\\}foo\': This element is not expected\\..+#');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/propertyinvalid.xml';

Expand Down Expand Up @@ -203,7 +203,7 @@ public function testCreateWithNonexistentPropertyYaml()
public function testCreateWithMalformedResourcesSettingYaml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"resources" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/resourcesinvalid\\.yml"\\./');
$this->expectExceptionMessageMatches('/"resources" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/resourcesinvalid\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/resourcesinvalid.yml';

Expand All @@ -213,7 +213,7 @@ public function testCreateWithMalformedResourcesSettingYaml()
public function testCreateWithMalformedPropertiesSettingYaml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"properties" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertiesinvalid\\.yml"\\./');
$this->expectExceptionMessageMatches('/"properties" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertiesinvalid\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/propertiesinvalid.yml';

Expand All @@ -223,7 +223,7 @@ public function testCreateWithMalformedPropertiesSettingYaml()
public function testCreateWithMalformedPropertySettingYaml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"foo" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertyinvalid\\.yml"\\./');
$this->expectExceptionMessageMatches('/"foo" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertyinvalid\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/propertyinvalid.yml';

Expand Down
Expand Up @@ -67,7 +67,7 @@ public function testCreateWithNonexistentResourceXml()
public function testCreateWithInvalidXml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('#.+Element \'\\{https://api-platform.com/schema/metadata\\}foo\': This element is not expected\\..+#');
$this->expectExceptionMessageMatches('#.+Element \'\\{https://api-platform.com/schema/metadata\\}foo\': This element is not expected\\..+#');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/propertyinvalid.xml';

Expand Down Expand Up @@ -113,7 +113,7 @@ public function testCreateWithNonexistentResourceYaml()
public function testCreateWithMalformedResourcesSettingYaml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"resources" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/resourcesinvalid\\.yml"\\./');
$this->expectExceptionMessageMatches('/"resources" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/resourcesinvalid\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/resourcesinvalid.yml';

Expand All @@ -123,7 +123,7 @@ public function testCreateWithMalformedResourcesSettingYaml()
public function testCreateWithMalformedPropertiesSettingYaml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"properties" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertiesinvalid\\.yml"\\./');
$this->expectExceptionMessageMatches('/"properties" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertiesinvalid\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/propertiesinvalid.yml';

Expand All @@ -133,7 +133,7 @@ public function testCreateWithMalformedPropertiesSettingYaml()
public function testCreateWithMalformedPropertySettingYaml()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"foo" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertyinvalid\\.yml"\\./');
$this->expectExceptionMessageMatches('/"foo" setting is expected to be null or an array, string given in ".+\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/Fixtures\\/FileConfigurations\\/propertyinvalid\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/propertyinvalid.yml';

Expand Down
Expand Up @@ -260,7 +260,7 @@ public function testCreateWithMalformedYaml()
public function testCreateWithBadDeclaration()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessageRegExp('/"ApiPlatform\\\\Core\\\\Tests\\\\Fixtures\\\\TestBundle\\\\Entity\\\\Dummy" setting is expected to be null or an array, string given in ".+\\/Fixtures\\/FileConfigurations\\/bad_declaration\\.yml"\\./');
$this->expectExceptionMessageMatches('/"ApiPlatform\\\\Core\\\\Tests\\\\Fixtures\\\\TestBundle\\\\Entity\\\\Dummy" setting is expected to be null or an array, string given in ".+\\/Fixtures\\/FileConfigurations\\/bad_declaration\\.yml"\\./');

$configPath = __DIR__.'/../../../Fixtures/FileConfigurations/bad_declaration.yml';

Expand Down