diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 79b03ebe42..7edf193643 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -40,6 +40,10 @@ parameters: ApiPlatform\Metadata\Resource\ResourceMetadataCollection: - handleNotFound ignoreErrors: + # BC shims for the test helpers moved to api-platform/test in 5.0 + - + identifier: trait.unused + path: src/Symfony/Bundle/Test/* # ignore type todo remove in 5.0 - message: '#Symfony\\Component\\PropertyInfo\\Type#' @@ -84,8 +88,6 @@ parameters: # Expected, due to backward compatibility - '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#' - "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\PropertyInfo\\\\\\\\PropertyInfoExtractor' and 'getType' will always evaluate to true\\.#" - - "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\HttpFoundation\\\\\\\\Request' and 'getContentTypeFormat' will always evaluate to true\\.#" - - '#Call to an undefined method Symfony\\Component\\HttpFoundation\\Request::getContentType\(\)\.#' - "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\Serializer\\\\\\\\Serializer' and 'getSupportedTypes' will always evaluate to true\\.#" - "#Call to function method_exists\\(\\) with Doctrine\\\\ODM\\\\MongoDB\\\\Mapping\\\\ClassMetadata\\|Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata and 'isChangeTrackingDef…' will always evaluate to true\\.#" - "#Call to function method_exists\\(\\) with Symfony\\\\Component\\\\Serializer\\\\Exception\\\\PartialDenormalizationException and 'getNotNormalizableV…' will always evaluate to true\\.#" diff --git a/src/GraphQl/Tests/Action/EntrypointActionTest.php b/src/GraphQl/Tests/Action/EntrypointActionTest.php index 3da6d37c96..3e6a5bac9e 100644 --- a/src/GraphQl/Tests/Action/EntrypointActionTest.php +++ b/src/GraphQl/Tests/Action/EntrypointActionTest.php @@ -265,6 +265,7 @@ private function getEntrypointAction(array $variables = ['graphqlVariable']): En $twigProphecy = $this->prophesize(TwigEnvironment::class); $twigProphecy->render(Argument::cetera())->willReturn(''); + $twigProphecy->getFunction('csp_nonce')->willReturn(null); $routerProphecy = $this->prophesize(RouterInterface::class); $routerProphecy->generate('api_graphql_entrypoint')->willReturn('/graphiql'); diff --git a/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php b/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php new file mode 100644 index 0000000000..7fc0744806 --- /dev/null +++ b/src/Symfony/Bundle/Test/ApiTestAssertionsTrait.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test; + +use ApiPlatform\Test\ApiTestAssertionsTrait as BaseApiTestAssertionsTrait; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" trait is deprecated, use "%s" instead.', ApiTestAssertionsTrait::class, BaseApiTestAssertionsTrait::class); + +/** + * @deprecated since API Platform 5.0, use {@see BaseApiTestAssertionsTrait} instead + */ +trait ApiTestAssertionsTrait +{ + use BaseApiTestAssertionsTrait; +} diff --git a/src/Symfony/Bundle/Test/ApiTestCase.php b/src/Symfony/Bundle/Test/ApiTestCase.php new file mode 100644 index 0000000000..12a707d5ca --- /dev/null +++ b/src/Symfony/Bundle/Test/ApiTestCase.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test; + +use ApiPlatform\Test\ApiTestCase as BaseApiTestCase; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" class is deprecated, use "%s" instead.', ApiTestCase::class, BaseApiTestCase::class); + +/** + * @deprecated since API Platform 5.0, use {@see BaseApiTestCase} instead + */ +abstract class ApiTestCase extends BaseApiTestCase +{ +} diff --git a/src/Symfony/Bundle/Test/Client.php b/src/Symfony/Bundle/Test/Client.php new file mode 100644 index 0000000000..334e608037 --- /dev/null +++ b/src/Symfony/Bundle/Test/Client.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test; + +use ApiPlatform\Test\Client; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" class is deprecated, use "%s" instead.', 'ApiPlatform\Symfony\Bundle\Test\Client', Client::class); + +class_alias(Client::class, 'ApiPlatform\Symfony\Bundle\Test\Client'); diff --git a/src/Symfony/Bundle/Test/ClientTrait.php b/src/Symfony/Bundle/Test/ClientTrait.php new file mode 100644 index 0000000000..fad941cea8 --- /dev/null +++ b/src/Symfony/Bundle/Test/ClientTrait.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test; + +use ApiPlatform\Test\ClientTrait as BaseClientTrait; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" trait is deprecated, use "%s" instead.', ClientTrait::class, BaseClientTrait::class); + +/** + * @deprecated since API Platform 5.0, use {@see BaseClientTrait} instead + */ +trait ClientTrait +{ + use BaseClientTrait; +} diff --git a/src/Symfony/Bundle/Test/Constraint/ArraySubset.php b/src/Symfony/Bundle/Test/Constraint/ArraySubset.php new file mode 100644 index 0000000000..bef08de6f9 --- /dev/null +++ b/src/Symfony/Bundle/Test/Constraint/ArraySubset.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test\Constraint; + +use ApiPlatform\Test\Constraint\ArraySubset; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" class is deprecated, use "%s" instead.', 'ApiPlatform\Symfony\Bundle\Test\Constraint\ArraySubset', ArraySubset::class); + +class_alias(ArraySubset::class, 'ApiPlatform\Symfony\Bundle\Test\Constraint\ArraySubset'); diff --git a/src/Symfony/Bundle/Test/Constraint/ArraySubsetTrait.php b/src/Symfony/Bundle/Test/Constraint/ArraySubsetTrait.php new file mode 100644 index 0000000000..9bed55ef61 --- /dev/null +++ b/src/Symfony/Bundle/Test/Constraint/ArraySubsetTrait.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test\Constraint; + +use ApiPlatform\Test\Constraint\ArraySubsetTrait as BaseArraySubsetTrait; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" trait is deprecated, use "%s" instead.', ArraySubsetTrait::class, BaseArraySubsetTrait::class); + +/** + * @deprecated since API Platform 5.0, use {@see BaseArraySubsetTrait} instead + */ +trait ArraySubsetTrait +{ + use BaseArraySubsetTrait; +} diff --git a/src/Symfony/Bundle/Test/Constraint/MatchesJsonSchema.php b/src/Symfony/Bundle/Test/Constraint/MatchesJsonSchema.php new file mode 100644 index 0000000000..7f78fc6b4b --- /dev/null +++ b/src/Symfony/Bundle/Test/Constraint/MatchesJsonSchema.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test\Constraint; + +use ApiPlatform\Test\Constraint\MatchesJsonSchema; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" class is deprecated, use "%s" instead.', 'ApiPlatform\Symfony\Bundle\Test\Constraint\MatchesJsonSchema', MatchesJsonSchema::class); + +class_alias(MatchesJsonSchema::class, 'ApiPlatform\Symfony\Bundle\Test\Constraint\MatchesJsonSchema'); diff --git a/src/Symfony/Bundle/Test/Response.php b/src/Symfony/Bundle/Test/Response.php new file mode 100644 index 0000000000..ed846c3f04 --- /dev/null +++ b/src/Symfony/Bundle/Test/Response.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace ApiPlatform\Symfony\Bundle\Test; + +use ApiPlatform\Test\Response; + +trigger_deprecation('api-platform/core', '5.0', 'The "%s" class is deprecated, use "%s" instead.', 'ApiPlatform\Symfony\Bundle\Test\Response', Response::class); + +class_alias(Response::class, 'ApiPlatform\Symfony\Bundle\Test\Response'); diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index b920fa082b..05b3e9633b 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -37,9 +37,11 @@ "api-platform/metadata": "^5.0@alpha", "api-platform/serializer": "^5.0@alpha", "api-platform/state": "^5.0@alpha", + "api-platform/test": "^5.0@alpha", "api-platform/validator": "^5.0@alpha", "api-platform/openapi": "^5.0@alpha", "symfony/asset": "^7.4 || ^8.0", + "symfony/deprecation-contracts": "^3.1", "symfony/finder": "^7.4 || ^8.0", "symfony/http-kernel": "^7.4 || ^8.0", "symfony/property-info": "^7.4 || ^8.0", diff --git a/tests/Functional/Doctrine/JoinedInheritanceSerializerGroupsTest.php b/tests/Functional/Doctrine/JoinedInheritanceSerializerGroupsTest.php index e9a714cada..8b4221de2e 100644 --- a/tests/Functional/Doctrine/JoinedInheritanceSerializerGroupsTest.php +++ b/tests/Functional/Doctrine/JoinedInheritanceSerializerGroupsTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Doctrine; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue8113\BarJoined; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue8113\BarJoinedA; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue8113\BarJoinedB; diff --git a/tests/Functional/GraphQl/GraphiqlCspNonceTest.php b/tests/Functional/GraphQl/GraphiqlCspNonceTest.php index d773636a7c..18e1c97ba5 100644 --- a/tests/Functional/GraphQl/GraphiqlCspNonceTest.php +++ b/tests/Functional/GraphQl/GraphiqlCspNonceTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\GraphQl; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Event\RequestEvent; diff --git a/tests/Functional/McpExceptionTest.php b/tests/Functional/McpExceptionTest.php index d1707c0d47..a3fc54fcf4 100644 --- a/tests/Functional/McpExceptionTest.php +++ b/tests/Functional/McpExceptionTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\McpExceptionTools; use ApiPlatform\Tests\RecreateSchemaTrait; use ApiPlatform\Tests\SetupClassResourcesTrait; diff --git a/tests/Functional/Parameters/ChainFilterMongoDbTest.php b/tests/Functional/Parameters/ChainFilterMongoDbTest.php index f3fd5c6c85..bb425f520b 100644 --- a/tests/Functional/Parameters/ChainFilterMongoDbTest.php +++ b/tests/Functional/Parameters/ChainFilterMongoDbTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Parameters; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\Document\ChainFilterParameter; use ApiPlatform\Tests\RecreateSchemaTrait; use ApiPlatform\Tests\SetupClassResourcesTrait; diff --git a/tests/Functional/Parameters/ChainFilterTest.php b/tests/Functional/Parameters/ChainFilterTest.php index c68aa900da..8f3ce6aee1 100644 --- a/tests/Functional/Parameters/ChainFilterTest.php +++ b/tests/Functional/Parameters/ChainFilterTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Parameters; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\ChainFilterParameter; use ApiPlatform\Tests\RecreateSchemaTrait; use ApiPlatform\Tests\SetupClassResourcesTrait; diff --git a/tests/Functional/Parameters/ParameterOnPropertiesTest.php b/tests/Functional/Parameters/ParameterOnPropertiesTest.php index cd0d5c04cc..4dbd3e8511 100644 --- a/tests/Functional/Parameters/ParameterOnPropertiesTest.php +++ b/tests/Functional/Parameters/ParameterOnPropertiesTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Parameters; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\Document\ParameterOnProperties as DocumentParameterOnProperties; use ApiPlatform\Tests\Fixtures\TestBundle\Document\ParameterOnPropertiesWithHeaderParameter as DocumentParameterOnPropertiesWithHeaderParameter; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\ParameterOnProperties; diff --git a/tests/Functional/Parameters/UriVariableParameterProviderTest.php b/tests/Functional/Parameters/UriVariableParameterProviderTest.php index a9437169b3..b7307a9cc2 100644 --- a/tests/Functional/Parameters/UriVariableParameterProviderTest.php +++ b/tests/Functional/Parameters/UriVariableParameterProviderTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Parameters; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\WriteUriVariableLinkResource; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Base64UriVariableDummy; use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy; diff --git a/tests/Functional/RepeatedDefaultParametersTest.php b/tests/Functional/RepeatedDefaultParametersTest.php index 9b713b562f..db0b2f6bd4 100644 --- a/tests/Functional/RepeatedDefaultParametersTest.php +++ b/tests/Functional/RepeatedDefaultParametersTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; final class RepeatedDefaultParametersTest extends ApiTestCase { diff --git a/tests/Functional/Serializer/EmbeddedRelationNativeTypeTest.php b/tests/Functional/Serializer/EmbeddedRelationNativeTypeTest.php index 849bca7ed0..cfd823a7c0 100644 --- a/tests/Functional/Serializer/EmbeddedRelationNativeTypeTest.php +++ b/tests/Functional/Serializer/EmbeddedRelationNativeTypeTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Serializer; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\EmbeddedRelationNativeType\EmbeddedRelationChild; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\EmbeddedRelationNativeType\EmbeddedRelationParent; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\EmbeddedRelationNativeType\EmbeddedRelationTarget; diff --git a/tests/Functional/Serializer/SharedRouteIriTest.php b/tests/Functional/Serializer/SharedRouteIriTest.php index 2e28514049..4585b40c05 100644 --- a/tests/Functional/Serializer/SharedRouteIriTest.php +++ b/tests/Functional/Serializer/SharedRouteIriTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional\Serializer; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\SharedRouteIri\CategoryProjection; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\SharedRouteIri\CategoryResource; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\SharedRouteIri\TopicResource; diff --git a/tests/Functional/SwaggerUiCspNonceTest.php b/tests/Functional/SwaggerUiCspNonceTest.php index 7971b2ada7..a1731c1372 100644 --- a/tests/Functional/SwaggerUiCspNonceTest.php +++ b/tests/Functional/SwaggerUiCspNonceTest.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Tests\Functional; -use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use ApiPlatform\Test\ApiTestCase; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Event\RequestEvent;