From be9bbd1542026512214e7558d3290047bfe5218b Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Mon, 26 Sep 2022 21:44:27 +0200 Subject: [PATCH] v5 --- README.md | 50 +++++------ composer.json | 7 +- doc/ApiProblem/ApiProblem.md | 16 ---- doc/Manager/ResponseManager.md | 10 +-- doc/Serialization/ApiProblemMapping.md | 19 ---- doc/ServiceProvider/ApiHttpServiceProvider.md | 22 ----- src/ApiProblem/AbstractApiProblem.php | 50 ----------- src/ApiProblem/ApiProblemInterface.php | 23 ----- src/ApiProblem/ClientError/BadRequest.php | 32 ------- src/ApiProblem/ClientError/Conflict.php | 21 ----- .../ClientError/ExpectationFailed.php | 32 ------- .../ClientError/FailedDependency.php | 21 ----- src/ApiProblem/ClientError/Forbidden.php | 21 ----- src/ApiProblem/ClientError/Gone.php | 21 ----- src/ApiProblem/ClientError/LengthRequired.php | 21 ----- src/ApiProblem/ClientError/Locked.php | 21 ----- .../ClientError/MethodNotAllowed.php | 50 ----------- src/ApiProblem/ClientError/NotAcceptable.php | 41 --------- src/ApiProblem/ClientError/NotFound.php | 21 ----- .../ClientError/PaymentRequired.php | 32 ------- .../ClientError/PreconditionFailed.php | 32 ------- .../ProxyAuthenticationRequired.php | 21 ----- .../ClientError/RequestEntityTooLarge.php | 26 ------ src/ApiProblem/ClientError/RequestTimeout.php | 21 ----- .../ClientError/RequestUriTooLong.php | 26 ------ .../RequestedRangeNotSatisfiable.php | 21 ----- src/ApiProblem/ClientError/Unauthorized.php | 49 ----------- .../ClientError/UnprocessableEntity.php | 32 ------- .../ClientError/UnsupportedMediaType.php | 41 --------- src/ApiProblem/ServerError/BadGateway.php | 21 ----- src/ApiProblem/ServerError/GatewayTimeout.php | 21 ----- .../ServerError/HttpVersionNotSupported.php | 21 ----- .../ServerError/InsufficientStorage.php | 21 ----- .../ServerError/InternalServerError.php | 42 --------- src/ApiProblem/ServerError/NotImplemented.php | 21 ----- .../ServerError/ServiceUnavailable.php | 21 ----- src/Manager/ResponseManager.php | 15 ++-- src/Manager/ResponseManagerInterface.php | 7 +- .../AcceptAndContentTypeMiddleware.php | 27 +++--- src/Middleware/ApiExceptionMiddleware.php | 12 +-- .../ApiProblem/AbstractApiProblemMapping.php | 47 ---------- .../ClientError/BadRequestMapping.php | 30 ------- .../ClientError/ConflictMapping.php | 16 ---- .../ClientError/ExpectationFailedMapping.php | 30 ------- .../ClientError/FailedDependencyMapping.php | 16 ---- .../ClientError/ForbiddenMapping.php | 16 ---- .../ApiProblem/ClientError/GoneMapping.php | 16 ---- .../ClientError/LengthRequiredMapping.php | 16 ---- .../ApiProblem/ClientError/LockedMapping.php | 16 ---- .../ClientError/MethodNotAllowedMapping.php | 31 ------- .../ClientError/NotAcceptableMapping.php | 31 ------- .../ClientError/NotFoundMapping.php | 16 ---- .../ClientError/PaymentRequiredMapping.php | 30 ------- .../ClientError/PreconditionFailedMapping.php | 30 ------- .../ProxyAuthenticationRequiredMapping.php | 16 ---- .../RequestEntityTooLargeMapping.php | 30 ------- .../ClientError/RequestTimeoutMapping.php | 16 ---- .../ClientError/RequestUriTooLongMapping.php | 30 ------- .../RequestedRangeNotSatisfiableMapping.php | 16 ---- .../ClientError/UnauthorizedMapping.php | 31 ------- .../UnprocessableEntityMapping.php | 30 ------- .../UnsupportedMediaTypeMapping.php | 31 ------- .../ServerError/BadGatewayMapping.php | 16 ---- .../ServerError/GatewayTimeoutMapping.php | 16 ---- .../HttpVersionNotSupportedMapping.php | 16 ---- .../InsufficientStorageMapping.php | 16 ---- .../InternalServerErrorMapping.php | 30 ------- .../ServerError/NotImplementedMapping.php | 16 ---- .../ServerError/ServiceUnavailableMapping.php | 16 ---- .../ApiHttpServiceProvider.php | 27 ------ tests/Unit/ApiProblem/ApiProblemTest.php | 50 ----------- .../ApiProblem/ClientError/BadRequestTest.php | 60 ------------- .../ApiProblem/ClientError/ConflictTest.php | 40 --------- .../ClientError/ExpectationFailedTest.php | 42 --------- .../ClientError/FailedDependencyTest.php | 40 --------- .../ApiProblem/ClientError/ForbiddenTest.php | 40 --------- .../Unit/ApiProblem/ClientError/GoneTest.php | 40 --------- .../ClientError/LengthRequiredTest.php | 40 --------- .../ApiProblem/ClientError/LockedTest.php | 40 --------- .../ClientError/MethodNotAllowedTest.php | 44 ---------- .../ClientError/NotAcceptableTest.php | 47 ---------- .../ApiProblem/ClientError/NotFoundTest.php | 40 --------- .../ClientError/PaymentRequiredTest.php | 42 --------- .../ClientError/PreconditionFailedTest.php | 42 --------- .../ProxyAuthenticationRequiredTest.php | 40 --------- .../ClientError/RequestEntityTooLargeTest.php | 42 --------- .../ClientError/RequestTimeoutTest.php | 40 --------- .../ClientError/RequestUriTooLongTest.php | 42 --------- .../RequestedRangeNotSatisfiableTest.php | 40 --------- .../ClientError/UnauthorizedTest.php | 44 ---------- .../ClientError/UnprocessableEntityTest.php | 60 ------------- .../ClientError/UnsupportedMediaTypeTest.php | 49 ----------- .../ApiProblem/ServerError/BadGatewayTest.php | 40 --------- .../ServerError/GatewayTimeoutTest.php | 40 --------- .../HttpVersionNotSupportedTest.php | 40 --------- .../ServerError/InsufficientStorageTest.php | 40 --------- .../ServerError/InternalServerErrorTest.php | 51 ----------- .../ServerError/NotImplementedTest.php | 40 --------- .../ServerError/ServiceUnavailableTest.php | 40 --------- tests/Unit/Manager/ResponseManagerTest.php | 23 +++-- .../AcceptAndContentTypeMiddlewareTest.php | 29 +++--- .../Middleware/ApiExceptionMiddlewareTest.php | 41 +++++---- .../ApiProblem/ApiProblemMappingTest.php | 88 ------------------- .../ClientError/BadRequestMappingTest.php | 65 -------------- .../ClientError/ConflictMappingTest.php | 64 -------------- .../ExpectationFailedMappingTest.php | 65 -------------- .../FailedDependencyMappingTest.php | 64 -------------- .../ClientError/ForbiddenMappingTest.php | 64 -------------- .../ClientError/GoneMappingTest.php | 64 -------------- .../ClientError/LengthRequiredMappingTest.php | 64 -------------- .../ClientError/LockedMappingTest.php | 64 -------------- .../MethodNotAllowedMappingTest.php | 66 -------------- .../ClientError/NotAcceptableMappingTest.php | 66 -------------- .../ClientError/NotFoundMappingTest.php | 64 -------------- .../PaymentRequiredMappingTest.php | 65 -------------- .../PreconditionFailedMappingTest.php | 65 -------------- ...ProxyAuthenticationRequiredMappingTest.php | 64 -------------- .../RequestEntityTooLargeMappingTest.php | 65 -------------- .../ClientError/RequestTimeoutMappingTest.php | 64 -------------- .../RequestUriTooLongMappingTest.php | 65 -------------- ...equestedRangeNotSatisfiableMappingTest.php | 64 -------------- .../ClientError/UnauthorizedMappingTest.php | 66 -------------- .../UnprocessableEntityMappingTest.php | 65 -------------- .../UnsupportedMediaTypeMappingTest.php | 66 -------------- .../ServerError/BadGatewayMappingTest.php | 64 -------------- .../ServerError/GatewayTimeoutMappingTest.php | 64 -------------- .../HttpVersionNotSupportedMappingTest.php | 64 -------------- .../InsufficientStorageMappingTest.php | 64 -------------- .../InternalServerErrorMappingTest.php | 65 -------------- .../ServerError/NotImplementedMappingTest.php | 64 -------------- .../ServiceUnavailableMappingTest.php | 64 -------------- .../ApiHttpServiceProviderTest.php | 56 ------------ 132 files changed, 119 insertions(+), 4904 deletions(-) delete mode 100644 doc/ApiProblem/ApiProblem.md delete mode 100644 doc/Serialization/ApiProblemMapping.md delete mode 100644 doc/ServiceProvider/ApiHttpServiceProvider.md delete mode 100644 src/ApiProblem/AbstractApiProblem.php delete mode 100644 src/ApiProblem/ApiProblemInterface.php delete mode 100644 src/ApiProblem/ClientError/BadRequest.php delete mode 100644 src/ApiProblem/ClientError/Conflict.php delete mode 100644 src/ApiProblem/ClientError/ExpectationFailed.php delete mode 100644 src/ApiProblem/ClientError/FailedDependency.php delete mode 100644 src/ApiProblem/ClientError/Forbidden.php delete mode 100644 src/ApiProblem/ClientError/Gone.php delete mode 100644 src/ApiProblem/ClientError/LengthRequired.php delete mode 100644 src/ApiProblem/ClientError/Locked.php delete mode 100644 src/ApiProblem/ClientError/MethodNotAllowed.php delete mode 100644 src/ApiProblem/ClientError/NotAcceptable.php delete mode 100644 src/ApiProblem/ClientError/NotFound.php delete mode 100644 src/ApiProblem/ClientError/PaymentRequired.php delete mode 100644 src/ApiProblem/ClientError/PreconditionFailed.php delete mode 100644 src/ApiProblem/ClientError/ProxyAuthenticationRequired.php delete mode 100644 src/ApiProblem/ClientError/RequestEntityTooLarge.php delete mode 100644 src/ApiProblem/ClientError/RequestTimeout.php delete mode 100644 src/ApiProblem/ClientError/RequestUriTooLong.php delete mode 100644 src/ApiProblem/ClientError/RequestedRangeNotSatisfiable.php delete mode 100644 src/ApiProblem/ClientError/Unauthorized.php delete mode 100644 src/ApiProblem/ClientError/UnprocessableEntity.php delete mode 100644 src/ApiProblem/ClientError/UnsupportedMediaType.php delete mode 100644 src/ApiProblem/ServerError/BadGateway.php delete mode 100644 src/ApiProblem/ServerError/GatewayTimeout.php delete mode 100644 src/ApiProblem/ServerError/HttpVersionNotSupported.php delete mode 100644 src/ApiProblem/ServerError/InsufficientStorage.php delete mode 100644 src/ApiProblem/ServerError/InternalServerError.php delete mode 100644 src/ApiProblem/ServerError/NotImplemented.php delete mode 100644 src/ApiProblem/ServerError/ServiceUnavailable.php delete mode 100644 src/Serialization/ApiProblem/AbstractApiProblemMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/BadRequestMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/ConflictMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/ExpectationFailedMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/FailedDependencyMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/ForbiddenMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/GoneMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/LengthRequiredMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/LockedMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/MethodNotAllowedMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/NotAcceptableMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/NotFoundMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/PaymentRequiredMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/PreconditionFailedMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/RequestEntityTooLargeMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/RequestTimeoutMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/RequestUriTooLongMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/UnauthorizedMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/UnprocessableEntityMapping.php delete mode 100644 src/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/BadGatewayMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/GatewayTimeoutMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/HttpVersionNotSupportedMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/InsufficientStorageMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/InternalServerErrorMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/NotImplementedMapping.php delete mode 100644 src/Serialization/ApiProblem/ServerError/ServiceUnavailableMapping.php delete mode 100644 src/ServiceProvider/ApiHttpServiceProvider.php delete mode 100644 tests/Unit/ApiProblem/ApiProblemTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/BadRequestTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/ConflictTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/ExpectationFailedTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/FailedDependencyTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/ForbiddenTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/GoneTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/LengthRequiredTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/LockedTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/MethodNotAllowedTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/NotAcceptableTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/NotFoundTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/PaymentRequiredTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/PreconditionFailedTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/ProxyAuthenticationRequiredTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/RequestEntityTooLargeTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/RequestTimeoutTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/RequestUriTooLongTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/RequestedRangeNotSatisfiableTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/UnauthorizedTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/UnprocessableEntityTest.php delete mode 100644 tests/Unit/ApiProblem/ClientError/UnsupportedMediaTypeTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/BadGatewayTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/GatewayTimeoutTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/HttpVersionNotSupportedTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/InsufficientStorageTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/InternalServerErrorTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/NotImplementedTest.php delete mode 100644 tests/Unit/ApiProblem/ServerError/ServiceUnavailableTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ApiProblemMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/BadRequestMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/ConflictMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/ExpectationFailedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/FailedDependencyMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/ForbiddenMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/GoneMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/LengthRequiredMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/LockedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/MethodNotAllowedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/NotAcceptableMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/NotFoundMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/PaymentRequiredMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/PreconditionFailedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/RequestEntityTooLargeMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/RequestTimeoutMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/RequestUriTooLongMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/UnauthorizedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/UnprocessableEntityMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/BadGatewayMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/GatewayTimeoutMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/HttpVersionNotSupportedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/InsufficientStorageMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/InternalServerErrorMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/NotImplementedMappingTest.php delete mode 100644 tests/Unit/Serialization/ApiProblem/ServerError/ServiceUnavailableMappingTest.php delete mode 100644 tests/Unit/ServiceProvider/ApiHttpServiceProviderTest.php diff --git a/README.md b/README.md index 3427370..0a3bbaa 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,10 @@ A simple http handler implementation for API. ## Requirements * php: ^8.0 - * chubbyphp/chubbyphp-deserialization: ^3.4.1 + * chubbyphp/chubbyphp-deserialization: ^3.5.1 + * chubbyphp/chubbyphp-http-exception: ^1.0 * chubbyphp/chubbyphp-negotiation: ^1.9 - * chubbyphp/chubbyphp-serialization: ^3.2 + * chubbyphp/chubbyphp-serialization: ^3.3.1 * psr/http-factory: ^1.0.1 * psr/http-message: ^1.0.1 * psr/http-server-middleware: ^1.0.1 @@ -39,38 +40,33 @@ A simple http handler implementation for API. Through [Composer](http://getcomposer.org) as [chubbyphp/chubbyphp-api-http][1]. ```sh -composer require chubbyphp/chubbyphp-api-http "^4.2" +composer require chubbyphp/chubbyphp-api-http "^5.0" ``` ## Usage - * [ApiProblem (example)][2] - * [AcceptAndContentTypeMiddlewareFactory][3] - * [ApiExceptionMiddlewareFactory][4] - * [RequestManagerFactory][5] - * [ResponseManagerFactory][6] - * [RequestManager][7] - * [ResponseManager][8] - * [AcceptAndContentTypeMiddleware][9] - * [ApiExceptionMiddleware][10] - * [ApiHttpServiceFactory][11] - * [ApiHttpServiceProvider][12] - * [ApiProblemMapping (example)][13] + * [AcceptAndContentTypeMiddlewareFactory][2] + * [ApiExceptionMiddlewareFactory][3] + * [RequestManagerFactory][4] + * [ResponseManagerFactory][5] + * [RequestManager][6] + * [ResponseManager][7] + * [AcceptAndContentTypeMiddleware][8] + * [ApiExceptionMiddleware][9] + * [ApiHttpServiceFactory][10] ## Copyright Dominik Zogg 2022 [1]: https://packagist.org/packages/chubbyphp/chubbyphp-api-http -[2]: doc/ApiProblem/ApiProblem.md -[3]: doc/ServiceFactory/AcceptAndContentTypeMiddlewareFactory.md -[4]: doc/ServiceFactory/ApiExceptionMiddlewareFactory.md -[5]: doc/ServiceFactory/RequestManagerFactory.md -[6]: doc/ServiceFactory/ResponseManagerFactory.md -[7]: doc/Manager/RequestManager.md -[8]: doc/Manager/ResponseManager.md -[9]: doc/Middleware/AcceptAndContentTypeMiddleware.md -[10]: doc/Middleware/ApiExceptionMiddleware.md -[11]: doc/ServiceFactory/ApiHttpServiceFactory.md -[12]: doc/ServiceProvider/ApiHttpServiceProvider.md -[13]: doc/Serialization/ApiProblemMapping.md + +[2]: doc/ServiceFactory/AcceptAndContentTypeMiddlewareFactory.md +[3]: doc/ServiceFactory/ApiExceptionMiddlewareFactory.md +[4]: doc/ServiceFactory/RequestManagerFactory.md +[5]: doc/ServiceFactory/ResponseManagerFactory.md +[6]: doc/Manager/RequestManager.md +[7]: doc/Manager/ResponseManager.md +[8]: doc/Middleware/AcceptAndContentTypeMiddleware.md +[9]: doc/Middleware/ApiExceptionMiddleware.md +[10]: doc/ServiceFactory/ApiHttpServiceFactory.md diff --git a/composer.json b/composer.json index f74d6e1..bf015f2 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,10 @@ ], "require": { "php": "^8.0", - "chubbyphp/chubbyphp-deserialization": "^3.4.1", + "chubbyphp/chubbyphp-deserialization": "^3.5.1", + "chubbyphp/chubbyphp-http-exception": "^1.0", "chubbyphp/chubbyphp-negotiation": "^1.9", - "chubbyphp/chubbyphp-serialization": "^3.2", + "chubbyphp/chubbyphp-serialization": "^3.3.1", "psr/http-factory": "^1.0.1", "psr/http-message": "^1.0.1", "psr/http-server-middleware": "^1.0.1", @@ -48,7 +49,7 @@ }, "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "5.0-dev" } }, "scripts": { diff --git a/doc/ApiProblem/ApiProblem.md b/doc/ApiProblem/ApiProblem.md deleted file mode 100644 index 7e83627..0000000 --- a/doc/ApiProblem/ApiProblem.md +++ /dev/null @@ -1,16 +0,0 @@ -# ApiProblem - -```php - 'name', - 'reason' => 'constraint.type.invalidtype', - 'details' => [ - 'type' => 'integer', - 'wishedType' => 'string', - ], -]); -``` diff --git a/doc/Manager/ResponseManager.md b/doc/Manager/ResponseManager.md index 3ff711d..1c3dcdb 100644 --- a/doc/Manager/ResponseManager.md +++ b/doc/Manager/ResponseManager.md @@ -3,10 +3,10 @@ ```php createRedirect( 'https://www.google.com' ); -/** @var ApiProblemInterface $apiProblem */ -$apiProblem = ...; +/** @var HttpExceptionInterface $httpException */ +$httpException = ...; -$response = $responseManager->createFromApiProblem( - $apiProblem, +$response = $responseManager->createFromHttpException( + $httpException, 'application/json' ); ``` diff --git a/doc/Serialization/ApiProblemMapping.md b/doc/Serialization/ApiProblemMapping.md deleted file mode 100644 index 1995562..0000000 --- a/doc/Serialization/ApiProblemMapping.md +++ /dev/null @@ -1,19 +0,0 @@ -# ApiProblemMapping - -```php -register(new SerializationProvider()); - -$container->extend('serializer.normalizer.objectmappings', function (array $mappings) { - $mappings[] = new BadRequestMapping(); - - return $mappings; -}); -``` diff --git a/doc/ServiceProvider/ApiHttpServiceProvider.md b/doc/ServiceProvider/ApiHttpServiceProvider.md deleted file mode 100644 index 51ed81e..0000000 --- a/doc/ServiceProvider/ApiHttpServiceProvider.md +++ /dev/null @@ -1,22 +0,0 @@ -# ApiHttpServiceProvider - -```php -register(new DeserializationServiceProvider()); -$container->register(new SerializationServiceProvider()); -$container->register(new ApiHttpServiceProvider()); - -$container['api-http.request.manager']->getDataFromRequestQuery(...); - -$container['api-http.response.manager']->create(...); - -$container['api-http.response.factory']->createResponse(...); -// must be defined, implement the ResponseFactoryInterface -``` diff --git a/src/ApiProblem/AbstractApiProblem.php b/src/ApiProblem/AbstractApiProblem.php deleted file mode 100644 index 69bfb6d..0000000 --- a/src/ApiProblem/AbstractApiProblem.php +++ /dev/null @@ -1,50 +0,0 @@ -type; - } - - public function getStatus(): int - { - return $this->status; - } - - public function getTitle(): string - { - return $this->title; - } - - public function getDetail(): ?string - { - return $this->detail; - } - - public function getInstance(): ?string - { - return $this->instance; - } - - /** - * @return array - */ - public function getHeaders(): array - { - return []; - } -} diff --git a/src/ApiProblem/ApiProblemInterface.php b/src/ApiProblem/ApiProblemInterface.php deleted file mode 100644 index de75401..0000000 --- a/src/ApiProblem/ApiProblemInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - public function getHeaders(): array; -} diff --git a/src/ApiProblem/ClientError/BadRequest.php b/src/ApiProblem/ClientError/BadRequest.php deleted file mode 100644 index 997dcbb..0000000 --- a/src/ApiProblem/ClientError/BadRequest.php +++ /dev/null @@ -1,32 +0,0 @@ -> $invalidParameters - */ - public function __construct(private array $invalidParameters, ?string $detail = null, ?string $instance = null) - { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.1', - 400, - 'Bad Request', - $detail, - $instance - ); - } - - /** - * @return array> - */ - public function getInvalidParameters(): array - { - return $this->invalidParameters; - } -} diff --git a/src/ApiProblem/ClientError/Conflict.php b/src/ApiProblem/ClientError/Conflict.php deleted file mode 100644 index ac7ad2e..0000000 --- a/src/ApiProblem/ClientError/Conflict.php +++ /dev/null @@ -1,21 +0,0 @@ - $failedExpectations - */ - public function __construct(private array $failedExpectations, ?string $detail = null, ?string $instance = null) - { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.18', - 417, - 'Expectation Failed', - $detail, - $instance - ); - } - - /** - * @return array - */ - public function getFailedExpectations(): array - { - return $this->failedExpectations; - } -} diff --git a/src/ApiProblem/ClientError/FailedDependency.php b/src/ApiProblem/ClientError/FailedDependency.php deleted file mode 100644 index 4cc59ea..0000000 --- a/src/ApiProblem/ClientError/FailedDependency.php +++ /dev/null @@ -1,21 +0,0 @@ - $allowedMethods - */ - public function __construct( - private string $method, - private array $allowedMethods, - ?string $detail = null, - ?string $instance = null - ) { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.6', - 405, - 'Method Not Allowed', - $detail, - $instance - ); - } - - /** - * @return array - */ - public function getHeaders(): array - { - return ['Allow' => implode(',', $this->allowedMethods)]; - } - - public function getMethod(): string - { - return $this->method; - } - - /** - * @return array - */ - public function getAllowedMethods(): array - { - return $this->allowedMethods; - } -} diff --git a/src/ApiProblem/ClientError/NotAcceptable.php b/src/ApiProblem/ClientError/NotAcceptable.php deleted file mode 100644 index 32ce48d..0000000 --- a/src/ApiProblem/ClientError/NotAcceptable.php +++ /dev/null @@ -1,41 +0,0 @@ - $acceptables - */ - public function __construct( - private string $accept, - private array $acceptables, - ?string $detail = null, - ?string $instance = null - ) { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.7', - 406, - 'Not Acceptable', - $detail, - $instance - ); - } - - public function getAccept(): string - { - return $this->accept; - } - - /** - * @return array - */ - public function getAcceptables(): array - { - return $this->acceptables; - } -} diff --git a/src/ApiProblem/ClientError/NotFound.php b/src/ApiProblem/ClientError/NotFound.php deleted file mode 100644 index eb33332..0000000 --- a/src/ApiProblem/ClientError/NotFound.php +++ /dev/null @@ -1,21 +0,0 @@ - $paymentTypes - */ - public function __construct(private array $paymentTypes, ?string $detail = null, ?string $instance = null) - { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.3', - 402, - 'Payment Required', - $detail, - $instance - ); - } - - /** - * @return array - */ - public function getPaymentTypes(): array - { - return $this->paymentTypes; - } -} diff --git a/src/ApiProblem/ClientError/PreconditionFailed.php b/src/ApiProblem/ClientError/PreconditionFailed.php deleted file mode 100644 index c0e9730..0000000 --- a/src/ApiProblem/ClientError/PreconditionFailed.php +++ /dev/null @@ -1,32 +0,0 @@ - $failedPreconditions - */ - public function __construct(private array $failedPreconditions, ?string $detail = null, ?string $instance = null) - { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.13', - 412, - 'Precondition Failed', - $detail, - $instance - ); - } - - /** - * @return array - */ - public function getFailedPreconditions(): array - { - return $this->failedPreconditions; - } -} diff --git a/src/ApiProblem/ClientError/ProxyAuthenticationRequired.php b/src/ApiProblem/ClientError/ProxyAuthenticationRequired.php deleted file mode 100644 index 28fa0e2..0000000 --- a/src/ApiProblem/ClientError/ProxyAuthenticationRequired.php +++ /dev/null @@ -1,21 +0,0 @@ -maxContentLength; - } -} diff --git a/src/ApiProblem/ClientError/RequestTimeout.php b/src/ApiProblem/ClientError/RequestTimeout.php deleted file mode 100644 index ca9d929..0000000 --- a/src/ApiProblem/ClientError/RequestTimeout.php +++ /dev/null @@ -1,21 +0,0 @@ -maxUriLength; - } -} diff --git a/src/ApiProblem/ClientError/RequestedRangeNotSatisfiable.php b/src/ApiProblem/ClientError/RequestedRangeNotSatisfiable.php deleted file mode 100644 index ad9fc29..0000000 --- a/src/ApiProblem/ClientError/RequestedRangeNotSatisfiable.php +++ /dev/null @@ -1,21 +0,0 @@ - $authorizationTypes - */ - public function __construct( - private string $authorization, - private array $authorizationTypes, - ?string $detail = null, - ?string $instance = null - ) { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.2', - 401, - 'Unauthorized', - $detail, - $instance - ); - } - - /** - * @return array - */ - public function getHeaders(): array - { - return ['WWW-Authenticate' => implode(',', $this->authorizationTypes)]; - } - - public function getAuthorization(): string - { - return $this->authorization; - } - - /** - * @return array - */ - public function getAuthorizationTypes(): array - { - return $this->authorizationTypes; - } -} diff --git a/src/ApiProblem/ClientError/UnprocessableEntity.php b/src/ApiProblem/ClientError/UnprocessableEntity.php deleted file mode 100644 index 0a2b97a..0000000 --- a/src/ApiProblem/ClientError/UnprocessableEntity.php +++ /dev/null @@ -1,32 +0,0 @@ -> $invalidParameters - */ - public function __construct(private array $invalidParameters, ?string $detail = null, ?string $instance = null) - { - parent::__construct( - 'https://tools.ietf.org/html/rfc4918#section-11.2', - 422, - 'Unprocessable Entity', - $detail, - $instance - ); - } - - /** - * @return array> - */ - public function getInvalidParameters(): array - { - return $this->invalidParameters; - } -} diff --git a/src/ApiProblem/ClientError/UnsupportedMediaType.php b/src/ApiProblem/ClientError/UnsupportedMediaType.php deleted file mode 100644 index b729b62..0000000 --- a/src/ApiProblem/ClientError/UnsupportedMediaType.php +++ /dev/null @@ -1,41 +0,0 @@ - $supportedMediaTypes - */ - public function __construct( - private string $mediaType, - private array $supportedMediaTypes, - ?string $detail = null, - ?string $instance = null - ) { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.4.16', - 415, - 'Unsupported Media Type', - $detail, - $instance - ); - } - - public function getMediaType(): string - { - return $this->mediaType; - } - - /** - * @return array - */ - public function getSupportedMediaTypes(): array - { - return $this->supportedMediaTypes; - } -} diff --git a/src/ApiProblem/ServerError/BadGateway.php b/src/ApiProblem/ServerError/BadGateway.php deleted file mode 100644 index 3a76bdd..0000000 --- a/src/ApiProblem/ServerError/BadGateway.php +++ /dev/null @@ -1,21 +0,0 @@ -> - */ - private ?array $backtrace = null; - - public function __construct(?string $detail = null, ?string $instance = null) - { - parent::__construct( - 'https://tools.ietf.org/html/rfc2616#section-10.5.1', - 500, - 'Internal Server Error', - $detail, - $instance - ); - } - - /** - * @param null|array> $backtrace - */ - public function setBacktrace(?array $backtrace): void - { - $this->backtrace = $backtrace; - } - - /** - * @return null|array> - */ - public function getBacktrace(): ?array - { - return $this->backtrace; - } -} diff --git a/src/ApiProblem/ServerError/NotImplemented.php b/src/ApiProblem/ServerError/NotImplemented.php deleted file mode 100644 index bd2820e..0000000 --- a/src/ApiProblem/ServerError/NotImplemented.php +++ /dev/null @@ -1,21 +0,0 @@ -responseFactory->createResponse($status)->withHeader('Location', $location); } - public function createFromApiProblem( - ApiProblemInterface $apiProblem, + public function createFromHttpException( + HttpExceptionInterface $httpException, string $accept, - ?NormalizerContextInterface $context = null ): ResponseInterface { - $status = $apiProblem->getStatus(); + $status = $httpException->getStatus(); $response = $this->responseFactory->createResponse($status) ->withHeader('Content-Type', str_replace('/', '/problem+', $accept)) ; - foreach ($apiProblem->getHeaders() as $name => $value) { + $data = $httpException->jsonSerialize(); + + foreach ($data['headers'] ?? [] as $name => $value) { $response = $response->withHeader($name, $value); } - $body = $this->serializer->serialize($apiProblem, $accept, $context); + $body = $this->serializer->encode($data, $accept); $response->getBody()->write($body); diff --git a/src/Manager/ResponseManagerInterface.php b/src/Manager/ResponseManagerInterface.php index 4d13d29..c0e889f 100644 --- a/src/Manager/ResponseManagerInterface.php +++ b/src/Manager/ResponseManagerInterface.php @@ -4,7 +4,7 @@ namespace Chubbyphp\ApiHttp\Manager; -use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface; +use Chubbyphp\HttpException\HttpExceptionInterface; use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface; use Psr\Http\Message\ResponseInterface; @@ -21,9 +21,8 @@ public function createEmpty(string $accept, int $status = 204): ResponseInterfac public function createRedirect(string $location, int $status = 307): ResponseInterface; - public function createFromApiProblem( - ApiProblemInterface $apiProblem, + public function createFromHttpException( + HttpExceptionInterface $httpException, string $accept, - ?NormalizerContextInterface $context = null ): ResponseInterface; } diff --git a/src/Middleware/AcceptAndContentTypeMiddleware.php b/src/Middleware/AcceptAndContentTypeMiddleware.php index 37d9e53..6e77f0b 100644 --- a/src/Middleware/AcceptAndContentTypeMiddleware.php +++ b/src/Middleware/AcceptAndContentTypeMiddleware.php @@ -4,9 +4,8 @@ namespace Chubbyphp\ApiHttp\Middleware; -use Chubbyphp\ApiHttp\ApiProblem\ClientError\NotAcceptable; -use Chubbyphp\ApiHttp\ApiProblem\ClientError\UnsupportedMediaType; use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface; +use Chubbyphp\HttpException\HttpException; use Chubbyphp\Negotiation\AcceptNegotiatorInterface; use Chubbyphp\Negotiation\ContentTypeNegotiatorInterface; use Psr\Http\Message\ResponseInterface; @@ -28,12 +27,12 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if (null === $accept = $this->acceptNegotiator->negotiate($request)) { $supportedMediaTypes = $this->acceptNegotiator->getSupportedMediaTypes(); - return $this->responseManager->createFromApiProblem( - new NotAcceptable( - $request->getHeaderLine('Accept'), - $supportedMediaTypes - ), - $supportedMediaTypes[0] + return $this->responseManager->createFromHttpException( + HttpException::createNotAcceptable([ + 'accept' => $request->getHeaderLine('Accept'), + 'supported-accepts' => $supportedMediaTypes, + ]), + $supportedMediaTypes[0], ); } @@ -41,12 +40,12 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if (\in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true)) { if (null === $contentType = $this->contentTypeNegotiator->negotiate($request)) { - return $this->responseManager->createFromApiProblem( - new UnsupportedMediaType( - $request->getHeaderLine('Content-Type'), - $this->contentTypeNegotiator->getSupportedMediaTypes() - ), - $accept->getValue() + return $this->responseManager->createFromHttpException( + HttpException::createUnsupportedMediaType([ + 'content-type' => $request->getHeaderLine('Content-Type'), + 'supported-content-types' => $this->contentTypeNegotiator->getSupportedMediaTypes(), + ]), + $accept->getValue(), ); } diff --git a/src/Middleware/ApiExceptionMiddleware.php b/src/Middleware/ApiExceptionMiddleware.php index c2ef1ab..2d3e298 100644 --- a/src/Middleware/ApiExceptionMiddleware.php +++ b/src/Middleware/ApiExceptionMiddleware.php @@ -4,8 +4,8 @@ namespace Chubbyphp\ApiHttp\Middleware; -use Chubbyphp\ApiHttp\ApiProblem\ServerError\InternalServerError; use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface; +use Chubbyphp\HttpException\HttpException; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -45,13 +45,15 @@ private function handleException(ServerRequestInterface $request, \Throwable $ex } if ($this->debug) { - $internalServerError = new InternalServerError($exception->getMessage()); - $internalServerError->setBacktrace($backtrace); + $httpException = HttpException::createInternalServerError([ + 'detail' => $exception->getMessage(), + 'backtrace' => $backtrace, + ]); } else { - $internalServerError = new InternalServerError(); + $httpException = HttpException::createInternalServerError(); } - return $this->responseManager->createFromApiProblem($internalServerError, $accept); + return $this->responseManager->createFromHttpException($httpException, $accept); } /** diff --git a/src/Serialization/ApiProblem/AbstractApiProblemMapping.php b/src/Serialization/ApiProblem/AbstractApiProblemMapping.php deleted file mode 100644 index 9f505f0..0000000 --- a/src/Serialization/ApiProblem/AbstractApiProblemMapping.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - return [ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ]; - } - - /** - * @return array - */ - public function getNormalizationEmbeddedFieldMappings(string $path): array - { - return []; - } - - /** - * @return array - */ - public function getNormalizationLinkMappings(string $path): array - { - return []; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/BadRequestMapping.php b/src/Serialization/ApiProblem/ClientError/BadRequestMapping.php deleted file mode 100644 index 9b010dd..0000000 --- a/src/Serialization/ApiProblem/ClientError/BadRequestMapping.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('invalidParameters')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/ConflictMapping.php b/src/Serialization/ApiProblem/ClientError/ConflictMapping.php deleted file mode 100644 index ccdfa13..0000000 --- a/src/Serialization/ApiProblem/ClientError/ConflictMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('failedExpectations')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/FailedDependencyMapping.php b/src/Serialization/ApiProblem/ClientError/FailedDependencyMapping.php deleted file mode 100644 index f80aa51..0000000 --- a/src/Serialization/ApiProblem/ClientError/FailedDependencyMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('method')->getMapping(); - $fieldMappings[] = NormalizationFieldMappingBuilder::create('allowedMethods')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/NotAcceptableMapping.php b/src/Serialization/ApiProblem/ClientError/NotAcceptableMapping.php deleted file mode 100644 index d6b45e2..0000000 --- a/src/Serialization/ApiProblem/ClientError/NotAcceptableMapping.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('accept')->getMapping(); - $fieldMappings[] = NormalizationFieldMappingBuilder::create('acceptables')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/NotFoundMapping.php b/src/Serialization/ApiProblem/ClientError/NotFoundMapping.php deleted file mode 100644 index a4a95e9..0000000 --- a/src/Serialization/ApiProblem/ClientError/NotFoundMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('paymentTypes')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/PreconditionFailedMapping.php b/src/Serialization/ApiProblem/ClientError/PreconditionFailedMapping.php deleted file mode 100644 index d06be43..0000000 --- a/src/Serialization/ApiProblem/ClientError/PreconditionFailedMapping.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('failedPreconditions')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMapping.php b/src/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMapping.php deleted file mode 100644 index 9da10f9..0000000 --- a/src/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('maxContentLength')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/RequestTimeoutMapping.php b/src/Serialization/ApiProblem/ClientError/RequestTimeoutMapping.php deleted file mode 100644 index eec8255..0000000 --- a/src/Serialization/ApiProblem/ClientError/RequestTimeoutMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('maxUriLength')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMapping.php b/src/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMapping.php deleted file mode 100644 index 3d27f06..0000000 --- a/src/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('authorization')->getMapping(); - $fieldMappings[] = NormalizationFieldMappingBuilder::create('authorizationTypes')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/UnprocessableEntityMapping.php b/src/Serialization/ApiProblem/ClientError/UnprocessableEntityMapping.php deleted file mode 100644 index bf2d32e..0000000 --- a/src/Serialization/ApiProblem/ClientError/UnprocessableEntityMapping.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('invalidParameters')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMapping.php b/src/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMapping.php deleted file mode 100644 index c20e9a5..0000000 --- a/src/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMapping.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('mediaType')->getMapping(); - $fieldMappings[] = NormalizationFieldMappingBuilder::create('supportedMediaTypes')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ServerError/BadGatewayMapping.php b/src/Serialization/ApiProblem/ServerError/BadGatewayMapping.php deleted file mode 100644 index ae15b67..0000000 --- a/src/Serialization/ApiProblem/ServerError/BadGatewayMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ - public function getNormalizationFieldMappings(string $path): array - { - $fieldMappings = parent::getNormalizationFieldMappings($path); - - $fieldMappings[] = NormalizationFieldMappingBuilder::create('backtrace')->getMapping(); - - return $fieldMappings; - } -} diff --git a/src/Serialization/ApiProblem/ServerError/NotImplementedMapping.php b/src/Serialization/ApiProblem/ServerError/NotImplementedMapping.php deleted file mode 100644 index aa83d35..0000000 --- a/src/Serialization/ApiProblem/ServerError/NotImplementedMapping.php +++ /dev/null @@ -1,16 +0,0 @@ - new RequestManager($container['deserializer']); - - $container['api-http.response.manager'] = static fn () => new ResponseManager( - $container['api-http.response.factory'], - $container['serializer'] - ); - - $container['api-http.response.factory'] = static function (): void { - throw new \RuntimeException('Missing response factory, define service "api-http.response.factory"'); - }; - } -} diff --git a/tests/Unit/ApiProblem/ApiProblemTest.php b/tests/Unit/ApiProblem/ApiProblemTest.php deleted file mode 100644 index a23089f..0000000 --- a/tests/Unit/ApiProblem/ApiProblemTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://im-a-teapot.com', $apiProblem->getType()); - self::assertSame('Im a Teapot', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new class('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0') extends AbstractApiProblem { - public function __construct(?string $detail = null, ?string $instance = null) - { - parent::__construct('https://im-a-teapot.com', 418, 'Im a Teapot', $detail, $instance); - } - }; - - self::assertSame(418, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://im-a-teapot.com', $apiProblem->getType()); - self::assertSame('Im a Teapot', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/BadRequestTest.php b/tests/Unit/ApiProblem/ClientError/BadRequestTest.php deleted file mode 100644 index 202e641..0000000 --- a/tests/Unit/ApiProblem/ClientError/BadRequestTest.php +++ /dev/null @@ -1,60 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.1', $apiProblem->getType()); - self::assertSame('Bad Request', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame([], $apiProblem->getInvalidParameters()); - } - - public function testMaximal(): void - { - $apiProblem = new BadRequest([ - [ - 'name' => 'age', - 'reason' => 'must be a positive integer', - ], - [ - 'name' => 'color', - 'reason' => 'must be \'green\', \'red\' or \'blue\'', - ], - ], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(400, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.1', $apiProblem->getType()); - self::assertSame('Bad Request', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame([ - [ - 'name' => 'age', - 'reason' => 'must be a positive integer', - ], - [ - 'name' => 'color', - 'reason' => 'must be \'green\', \'red\' or \'blue\'', - ], - ], $apiProblem->getInvalidParameters()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/ConflictTest.php b/tests/Unit/ApiProblem/ClientError/ConflictTest.php deleted file mode 100644 index f46b4f0..0000000 --- a/tests/Unit/ApiProblem/ClientError/ConflictTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.10', $apiProblem->getType()); - self::assertSame('Conflict', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new Conflict('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(409, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.10', $apiProblem->getType()); - self::assertSame('Conflict', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/ExpectationFailedTest.php b/tests/Unit/ApiProblem/ClientError/ExpectationFailedTest.php deleted file mode 100644 index 512b057..0000000 --- a/tests/Unit/ApiProblem/ClientError/ExpectationFailedTest.php +++ /dev/null @@ -1,42 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.18', $apiProblem->getType()); - self::assertSame('Expectation Failed', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame([], $apiProblem->getFailedExpectations()); - } - - public function testMaximal(): void - { - $apiProblem = new ExpectationFailed(['Expectation Failed'], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(417, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.18', $apiProblem->getType()); - self::assertSame('Expectation Failed', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame(['Expectation Failed'], $apiProblem->getFailedExpectations()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/FailedDependencyTest.php b/tests/Unit/ApiProblem/ClientError/FailedDependencyTest.php deleted file mode 100644 index 270f018..0000000 --- a/tests/Unit/ApiProblem/ClientError/FailedDependencyTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.4', $apiProblem->getType()); - self::assertSame('Failed Dependency', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new FailedDependency('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(424, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.4', $apiProblem->getType()); - self::assertSame('Failed Dependency', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/ForbiddenTest.php b/tests/Unit/ApiProblem/ClientError/ForbiddenTest.php deleted file mode 100644 index 45a3ed9..0000000 --- a/tests/Unit/ApiProblem/ClientError/ForbiddenTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.4', $apiProblem->getType()); - self::assertSame('Forbidden', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new Forbidden('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(403, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.4', $apiProblem->getType()); - self::assertSame('Forbidden', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/GoneTest.php b/tests/Unit/ApiProblem/ClientError/GoneTest.php deleted file mode 100644 index aaea656..0000000 --- a/tests/Unit/ApiProblem/ClientError/GoneTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.11', $apiProblem->getType()); - self::assertSame('Gone', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new Gone('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(410, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.11', $apiProblem->getType()); - self::assertSame('Gone', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/LengthRequiredTest.php b/tests/Unit/ApiProblem/ClientError/LengthRequiredTest.php deleted file mode 100644 index c41453c..0000000 --- a/tests/Unit/ApiProblem/ClientError/LengthRequiredTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.12', $apiProblem->getType()); - self::assertSame('Length Required', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new LengthRequired('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(411, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.12', $apiProblem->getType()); - self::assertSame('Length Required', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/LockedTest.php b/tests/Unit/ApiProblem/ClientError/LockedTest.php deleted file mode 100644 index e02925e..0000000 --- a/tests/Unit/ApiProblem/ClientError/LockedTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.3', $apiProblem->getType()); - self::assertSame('Locked', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new Locked('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(423, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.3', $apiProblem->getType()); - self::assertSame('Locked', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/MethodNotAllowedTest.php b/tests/Unit/ApiProblem/ClientError/MethodNotAllowedTest.php deleted file mode 100644 index 1f68df6..0000000 --- a/tests/Unit/ApiProblem/ClientError/MethodNotAllowedTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getStatus()); - self::assertSame(['Allow' => ''], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.6', $apiProblem->getType()); - self::assertSame('Method Not Allowed', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame('PUT', $apiProblem->getMethod()); - self::assertSame([], $apiProblem->getAllowedMethods()); - } - - public function testMaximal(): void - { - $apiProblem = new MethodNotAllowed('PUT', ['GET', 'POST'], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(405, $apiProblem->getStatus()); - self::assertSame(['Allow' => 'GET,POST'], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.6', $apiProblem->getType()); - self::assertSame('Method Not Allowed', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame('PUT', $apiProblem->getMethod()); - self::assertSame(['GET', 'POST'], $apiProblem->getAllowedMethods()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/NotAcceptableTest.php b/tests/Unit/ApiProblem/ClientError/NotAcceptableTest.php deleted file mode 100644 index d977c59..0000000 --- a/tests/Unit/ApiProblem/ClientError/NotAcceptableTest.php +++ /dev/null @@ -1,47 +0,0 @@ -getStatus()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.7', $apiProblem->getType()); - self::assertSame('Not Acceptable', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame('application/x-yaml', $apiProblem->getAccept()); - self::assertSame([], $apiProblem->getAcceptables()); - } - - public function testMaximal(): void - { - $apiProblem = new NotAcceptable( - 'application/x-yaml', - ['application/json', 'application/xml'], - 'detail', - '/cccdfd0f-0da3-4070-8e55-61bd832b47c0' - ); - - self::assertSame(406, $apiProblem->getStatus()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.7', $apiProblem->getType()); - self::assertSame('Not Acceptable', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame('application/x-yaml', $apiProblem->getAccept()); - self::assertSame(['application/json', 'application/xml'], $apiProblem->getAcceptables()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/NotFoundTest.php b/tests/Unit/ApiProblem/ClientError/NotFoundTest.php deleted file mode 100644 index 4805150..0000000 --- a/tests/Unit/ApiProblem/ClientError/NotFoundTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.5', $apiProblem->getType()); - self::assertSame('Not Found', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new NotFound('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(404, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.5', $apiProblem->getType()); - self::assertSame('Not Found', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/PaymentRequiredTest.php b/tests/Unit/ApiProblem/ClientError/PaymentRequiredTest.php deleted file mode 100644 index c2a5778..0000000 --- a/tests/Unit/ApiProblem/ClientError/PaymentRequiredTest.php +++ /dev/null @@ -1,42 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.3', $apiProblem->getType()); - self::assertSame('Payment Required', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame([], $apiProblem->getPaymentTypes()); - } - - public function testMaximal(): void - { - $apiProblem = new PaymentRequired(['creditcard', 'paypal'], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(402, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.3', $apiProblem->getType()); - self::assertSame('Payment Required', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame(['creditcard', 'paypal'], $apiProblem->getPaymentTypes()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/PreconditionFailedTest.php b/tests/Unit/ApiProblem/ClientError/PreconditionFailedTest.php deleted file mode 100644 index c929e22..0000000 --- a/tests/Unit/ApiProblem/ClientError/PreconditionFailedTest.php +++ /dev/null @@ -1,42 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.13', $apiProblem->getType()); - self::assertSame('Precondition Failed', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame([], $apiProblem->getFailedPreconditions()); - } - - public function testMaximal(): void - { - $apiProblem = new PreconditionFailed(['Failed Precondition'], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(412, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.13', $apiProblem->getType()); - self::assertSame('Precondition Failed', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame(['Failed Precondition'], $apiProblem->getFailedPreconditions()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/ProxyAuthenticationRequiredTest.php b/tests/Unit/ApiProblem/ClientError/ProxyAuthenticationRequiredTest.php deleted file mode 100644 index aa623bc..0000000 --- a/tests/Unit/ApiProblem/ClientError/ProxyAuthenticationRequiredTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.8', $apiProblem->getType()); - self::assertSame('Proxy Authentication Required', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new ProxyAuthenticationRequired('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(407, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.8', $apiProblem->getType()); - self::assertSame('Proxy Authentication Required', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/RequestEntityTooLargeTest.php b/tests/Unit/ApiProblem/ClientError/RequestEntityTooLargeTest.php deleted file mode 100644 index a0c6bcf..0000000 --- a/tests/Unit/ApiProblem/ClientError/RequestEntityTooLargeTest.php +++ /dev/null @@ -1,42 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.14', $apiProblem->getType()); - self::assertSame('Request Entity Too Large', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame(1024, $apiProblem->getMaxContentLength()); - } - - public function testMaximal(): void - { - $apiProblem = new RequestEntityTooLarge(1024, 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(413, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.14', $apiProblem->getType()); - self::assertSame('Request Entity Too Large', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame(1024, $apiProblem->getMaxContentLength()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/RequestTimeoutTest.php b/tests/Unit/ApiProblem/ClientError/RequestTimeoutTest.php deleted file mode 100644 index e9e550e..0000000 --- a/tests/Unit/ApiProblem/ClientError/RequestTimeoutTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.9', $apiProblem->getType()); - self::assertSame('Request Timeout', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new RequestTimeout('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(408, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.9', $apiProblem->getType()); - self::assertSame('Request Timeout', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/RequestUriTooLongTest.php b/tests/Unit/ApiProblem/ClientError/RequestUriTooLongTest.php deleted file mode 100644 index 1b8030a..0000000 --- a/tests/Unit/ApiProblem/ClientError/RequestUriTooLongTest.php +++ /dev/null @@ -1,42 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.15', $apiProblem->getType()); - self::assertSame('Request Uri Too Long', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame(1024, $apiProblem->getMaxUriLength()); - } - - public function testMaximal(): void - { - $apiProblem = new RequestUriTooLong(1024, 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(414, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.15', $apiProblem->getType()); - self::assertSame('Request Uri Too Long', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame(1024, $apiProblem->getMaxUriLength()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/RequestedRangeNotSatisfiableTest.php b/tests/Unit/ApiProblem/ClientError/RequestedRangeNotSatisfiableTest.php deleted file mode 100644 index 27463ba..0000000 --- a/tests/Unit/ApiProblem/ClientError/RequestedRangeNotSatisfiableTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.17', $apiProblem->getType()); - self::assertSame('Requested Range Not Satisfiable', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new RequestedRangeNotSatisfiable('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(416, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.17', $apiProblem->getType()); - self::assertSame('Requested Range Not Satisfiable', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/UnauthorizedTest.php b/tests/Unit/ApiProblem/ClientError/UnauthorizedTest.php deleted file mode 100644 index 8aff2a4..0000000 --- a/tests/Unit/ApiProblem/ClientError/UnauthorizedTest.php +++ /dev/null @@ -1,44 +0,0 @@ -getStatus()); - self::assertSame(['WWW-Authenticate' => ''], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.2', $apiProblem->getType()); - self::assertSame('Unauthorized', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame('Token', $apiProblem->getAuthorization()); - self::assertSame([], $apiProblem->getAuthorizationTypes()); - } - - public function testMaximal(): void - { - $apiProblem = new Unauthorized('Token', ['Basic', 'Bearer'], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(401, $apiProblem->getStatus()); - self::assertSame(['WWW-Authenticate' => 'Basic,Bearer'], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.2', $apiProblem->getType()); - self::assertSame('Unauthorized', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame('Token', $apiProblem->getAuthorization()); - self::assertSame(['Basic', 'Bearer'], $apiProblem->getAuthorizationTypes()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/UnprocessableEntityTest.php b/tests/Unit/ApiProblem/ClientError/UnprocessableEntityTest.php deleted file mode 100644 index b21b31c..0000000 --- a/tests/Unit/ApiProblem/ClientError/UnprocessableEntityTest.php +++ /dev/null @@ -1,60 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.2', $apiProblem->getType()); - self::assertSame('Unprocessable Entity', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame([], $apiProblem->getInvalidParameters()); - } - - public function testMaximal(): void - { - $apiProblem = new UnprocessableEntity([ - [ - 'name' => 'age', - 'reason' => 'must be a positive integer', - ], - [ - 'name' => 'color', - 'reason' => 'must be \'green\', \'red\' or \'blue\'', - ], - ], 'detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(422, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.2', $apiProblem->getType()); - self::assertSame('Unprocessable Entity', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame([ - [ - 'name' => 'age', - 'reason' => 'must be a positive integer', - ], - [ - 'name' => 'color', - 'reason' => 'must be \'green\', \'red\' or \'blue\'', - ], - ], $apiProblem->getInvalidParameters()); - } -} diff --git a/tests/Unit/ApiProblem/ClientError/UnsupportedMediaTypeTest.php b/tests/Unit/ApiProblem/ClientError/UnsupportedMediaTypeTest.php deleted file mode 100644 index 2cd019f..0000000 --- a/tests/Unit/ApiProblem/ClientError/UnsupportedMediaTypeTest.php +++ /dev/null @@ -1,49 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.16', $apiProblem->getType()); - self::assertSame('Unsupported Media Type', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertSame('application/x-yaml', $apiProblem->getMediaType()); - self::assertSame([], $apiProblem->getSupportedMediaTypes()); - } - - public function testMaximal(): void - { - $apiProblem = new UnsupportedMediaType( - 'application/x-yaml', - ['application/json', 'application/xml'], - 'detail', - '/cccdfd0f-0da3-4070-8e55-61bd832b47c0' - ); - - self::assertSame(415, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.4.16', $apiProblem->getType()); - self::assertSame('Unsupported Media Type', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame('application/x-yaml', $apiProblem->getMediaType()); - self::assertSame(['application/json', 'application/xml'], $apiProblem->getSupportedMediaTypes()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/BadGatewayTest.php b/tests/Unit/ApiProblem/ServerError/BadGatewayTest.php deleted file mode 100644 index acc3b81..0000000 --- a/tests/Unit/ApiProblem/ServerError/BadGatewayTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.3', $apiProblem->getType()); - self::assertSame('Bad Gateway', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new BadGateway('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(502, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.3', $apiProblem->getType()); - self::assertSame('Bad Gateway', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/GatewayTimeoutTest.php b/tests/Unit/ApiProblem/ServerError/GatewayTimeoutTest.php deleted file mode 100644 index e51197d..0000000 --- a/tests/Unit/ApiProblem/ServerError/GatewayTimeoutTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.5', $apiProblem->getType()); - self::assertSame('Gateway Timeout', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new GatewayTimeout('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(504, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.5', $apiProblem->getType()); - self::assertSame('Gateway Timeout', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/HttpVersionNotSupportedTest.php b/tests/Unit/ApiProblem/ServerError/HttpVersionNotSupportedTest.php deleted file mode 100644 index fa0a554..0000000 --- a/tests/Unit/ApiProblem/ServerError/HttpVersionNotSupportedTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.6', $apiProblem->getType()); - self::assertSame('Http Version Not Supported', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new HttpVersionNotSupported('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(505, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.6', $apiProblem->getType()); - self::assertSame('Http Version Not Supported', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/InsufficientStorageTest.php b/tests/Unit/ApiProblem/ServerError/InsufficientStorageTest.php deleted file mode 100644 index 8a47571..0000000 --- a/tests/Unit/ApiProblem/ServerError/InsufficientStorageTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.5', $apiProblem->getType()); - self::assertSame('Insufficient Storage', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new InsufficientStorage('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(507, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc4918#section-11.5', $apiProblem->getType()); - self::assertSame('Insufficient Storage', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/InternalServerErrorTest.php b/tests/Unit/ApiProblem/ServerError/InternalServerErrorTest.php deleted file mode 100644 index e7087e7..0000000 --- a/tests/Unit/ApiProblem/ServerError/InternalServerErrorTest.php +++ /dev/null @@ -1,51 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.1', $apiProblem->getType()); - self::assertSame('Internal Server Error', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - self::assertNull($apiProblem->getBacktrace()); - } - - public function testMaximal(): void - { - $backtrace = [ - [ - 'class' => 'RuntimeException', - 'message' => 'runtime exception', - 'code' => 5000, - ], - ]; - - $apiProblem = new InternalServerError('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - $apiProblem->setBacktrace($backtrace); - - self::assertSame(500, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.1', $apiProblem->getType()); - self::assertSame('Internal Server Error', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - self::assertSame($backtrace, $apiProblem->getBacktrace()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/NotImplementedTest.php b/tests/Unit/ApiProblem/ServerError/NotImplementedTest.php deleted file mode 100644 index abbeaa1..0000000 --- a/tests/Unit/ApiProblem/ServerError/NotImplementedTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.2', $apiProblem->getType()); - self::assertSame('Not Implemented', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new NotImplemented('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(501, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.2', $apiProblem->getType()); - self::assertSame('Not Implemented', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/ApiProblem/ServerError/ServiceUnavailableTest.php b/tests/Unit/ApiProblem/ServerError/ServiceUnavailableTest.php deleted file mode 100644 index 1f0548b..0000000 --- a/tests/Unit/ApiProblem/ServerError/ServiceUnavailableTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.4', $apiProblem->getType()); - self::assertSame('Service Unavailable', $apiProblem->getTitle()); - self::assertNull($apiProblem->getDetail()); - self::assertNull($apiProblem->getInstance()); - } - - public function testMaximal(): void - { - $apiProblem = new ServiceUnavailable('detail', '/cccdfd0f-0da3-4070-8e55-61bd832b47c0'); - - self::assertSame(503, $apiProblem->getStatus()); - self::assertSame([], $apiProblem->getHeaders()); - self::assertSame('https://tools.ietf.org/html/rfc2616#section-10.5.4', $apiProblem->getType()); - self::assertSame('Service Unavailable', $apiProblem->getTitle()); - self::assertSame('detail', $apiProblem->getDetail()); - self::assertSame('/cccdfd0f-0da3-4070-8e55-61bd832b47c0', $apiProblem->getInstance()); - } -} diff --git a/tests/Unit/Manager/ResponseManagerTest.php b/tests/Unit/Manager/ResponseManagerTest.php index 657710e..f117d69 100644 --- a/tests/Unit/Manager/ResponseManagerTest.php +++ b/tests/Unit/Manager/ResponseManagerTest.php @@ -4,8 +4,8 @@ namespace Chubbyphp\Tests\ApiHttp\Unit\Manager; -use Chubbyphp\ApiHttp\ApiProblem\ApiProblemInterface; use Chubbyphp\ApiHttp\Manager\ResponseManager; +use Chubbyphp\HttpException\HttpException; use Chubbyphp\Mock\Call; use Chubbyphp\Mock\MockByCallsTrait; use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface; @@ -172,12 +172,10 @@ public function testCreateRedirectWithoutDefaults(): void self::assertSame($response, $responseManager->createRedirect('https://google.com', 301)); } - public function testCreateFromApiProblem(): void + public function testCreateFromHttpException(): void { - /** @var ApiProblemInterface|MockObject $apiProblem */ - $apiProblem = $this->getMockByCalls(ApiProblemInterface::class, [ - Call::create('getStatus')->with()->willReturn(405), - Call::create('getHeaders')->with()->willReturn(['Allow' => 'PATCH,PUT']), + $httpException = HttpException::createMethodNotAllowed([ + 'headers' => ['Allow' => 'PATCH,PUT'], ]); /** @var MockObject|StreamInterface $body */ @@ -199,13 +197,20 @@ public function testCreateFromApiProblem(): void /** @var MockObject|SerializerInterface $serializer */ $serializer = $this->getMockByCalls(SerializerInterface::class, [ - Call::create('serialize') - ->with($apiProblem, 'application/json', null, '') + Call::create('encode') + ->with([ + 'type' => 'https://datatracker.ietf.org/doc/html/rfc2616#section-10.4.6', + 'status' => 405, + 'title' => 'Method Not Allowed', + 'headers' => [ + 'Allow' => 'PATCH,PUT', + ], + ], 'application/json') ->willReturn('{"title":"Method Not Allowed"}'), ]); $responseManager = new ResponseManager($responseFactory, $serializer); - self::assertSame($response, $responseManager->createFromApiProblem($apiProblem, 'application/json')); + self::assertSame($response, $responseManager->createFromHttpException($httpException, 'application/json')); } } diff --git a/tests/Unit/Middleware/AcceptAndContentTypeMiddlewareTest.php b/tests/Unit/Middleware/AcceptAndContentTypeMiddlewareTest.php index ad0ec7e..6caa78a 100644 --- a/tests/Unit/Middleware/AcceptAndContentTypeMiddlewareTest.php +++ b/tests/Unit/Middleware/AcceptAndContentTypeMiddlewareTest.php @@ -4,10 +4,9 @@ namespace Chubbyphp\Tests\ApiHttp\Unit\Middleware; -use Chubbyphp\ApiHttp\ApiProblem\ClientError\NotAcceptable; -use Chubbyphp\ApiHttp\ApiProblem\ClientError\UnsupportedMediaType; use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface; use Chubbyphp\ApiHttp\Middleware\AcceptAndContentTypeMiddleware; +use Chubbyphp\HttpException\HttpExceptionInterface; use Chubbyphp\Mock\Argument\ArgumentCallback; use Chubbyphp\Mock\Call; use Chubbyphp\Mock\MockByCallsTrait; @@ -57,14 +56,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface /** @var MockObject|ResponseManagerInterface $responseManager */ $responseManager = $this->getMockByCalls(ResponseManagerInterface::class, [ - Call::create('createFromApiProblem') + Call::create('createFromHttpException') ->with( - new ArgumentCallback(static function (NotAcceptable $apiProblem): void { - self::assertSame('application/xml', $apiProblem->getAccept()); - self::assertSame(['application/json'], $apiProblem->getAcceptables()); + new ArgumentCallback(static function (HttpExceptionInterface $httpException): void { + self::assertSame(406, $httpException->getStatus()); + + $data = $httpException->jsonSerialize(); + + self::assertSame('application/xml', $data['accept']); + self::assertSame(['application/json'], $data['supported-accepts']); }), 'application/json', - null ) ->willReturn($response), ]); @@ -155,14 +157,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface /** @var MockObject|ResponseManagerInterface $responseManager */ $responseManager = $this->getMockByCalls(ResponseManagerInterface::class, [ - Call::create('createFromApiProblem') + Call::create('createFromHttpException') ->with( - new ArgumentCallback(static function (UnsupportedMediaType $apiProblem): void { - self::assertSame('application/xml', $apiProblem->getMediaType()); - self::assertSame(['application/json'], $apiProblem->getSupportedMediaTypes()); + new ArgumentCallback(static function (HttpExceptionInterface $httpException): void { + self::assertSame(415, $httpException->getStatus()); + + $data = $httpException->jsonSerialize(); + + self::assertSame('application/xml', $data['content-type']); + self::assertSame(['application/json'], $data['supported-content-types']); }), 'application/json', - null ) ->willReturn($response), ]); diff --git a/tests/Unit/Middleware/ApiExceptionMiddlewareTest.php b/tests/Unit/Middleware/ApiExceptionMiddlewareTest.php index 2718541..0b20dbb 100644 --- a/tests/Unit/Middleware/ApiExceptionMiddlewareTest.php +++ b/tests/Unit/Middleware/ApiExceptionMiddlewareTest.php @@ -4,9 +4,9 @@ namespace Chubbyphp\Tests\ApiHttp\Unit\Middleware; -use Chubbyphp\ApiHttp\ApiProblem\ServerError\InternalServerError; use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface; use Chubbyphp\ApiHttp\Middleware\ApiExceptionMiddleware; +use Chubbyphp\HttpException\HttpExceptionInterface; use Chubbyphp\Mock\Argument\ArgumentCallback; use Chubbyphp\Mock\Call; use Chubbyphp\Mock\MockByCallsTrait; @@ -135,12 +135,16 @@ public function handle(ServerRequestInterface $request): ResponseInterface /** @var MockObject|ResponseManagerInterface $responseManager */ $responseManager = $this->getMockByCalls(ResponseManagerInterface::class, [ - Call::create('createFromApiProblem') + Call::create('createFromHttpException') ->with( - new ArgumentCallback(static function (InternalServerError $error): void { - self::assertSame('runtime exception', $error->getDetail()); + new ArgumentCallback(static function (HttpExceptionInterface $httpException): void { + self::assertSame('Internal Server Error', $httpException->getTitle()); - $backtrace = $error->getBacktrace(); + $data = $httpException->jsonSerialize(); + + self::assertArrayHasKey('backtrace', $data); + + $backtrace = $data['backtrace']; self::assertCount(2, $backtrace); @@ -163,7 +167,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface self::assertArrayHasKey('trace', $exception); }), 'application/xml', - null ) ->willReturn($response), ]); @@ -223,14 +226,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface /** @var MockObject|ResponseManagerInterface $responseManager */ $responseManager = $this->getMockByCalls(ResponseManagerInterface::class, [ - Call::create('createFromApiProblem') + Call::create('createFromHttpException') ->with( - new ArgumentCallback(static function (InternalServerError $error): void { - self::assertNull($error->getDetail()); - self::assertNull($error->getBacktrace()); + new ArgumentCallback(static function (HttpExceptionInterface $httpException): void { + self::assertSame(500, $httpException->getStatus()); + + $data = $httpException->jsonSerialize(); + + self::assertArrayNotHasKey('detail', $data); + self::assertArrayNotHasKey('backtrace', $data); }), 'application/xml', - null ) ->willReturn($response), ]); @@ -290,14 +296,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface /** @var MockObject|ResponseManagerInterface $responseManager */ $responseManager = $this->getMockByCalls(ResponseManagerInterface::class, [ - Call::create('createFromApiProblem') + Call::create('createFromHttpException') ->with( - new ArgumentCallback(static function (InternalServerError $error): void { - self::assertNull($error->getDetail()); - self::assertNull($error->getBacktrace()); + new ArgumentCallback(static function (HttpExceptionInterface $httpException): void { + self::assertSame(500, $httpException->getStatus()); + + $data = $httpException->jsonSerialize(); + + self::assertArrayNotHasKey('detail', $data); + self::assertArrayNotHasKey('backtrace', $data); }), 'application/xml', - null ) ->willReturn($response), ]); diff --git a/tests/Unit/Serialization/ApiProblem/ApiProblemMappingTest.php b/tests/Unit/Serialization/ApiProblem/ApiProblemMappingTest.php deleted file mode 100644 index ebe8594..0000000 --- a/tests/Unit/Serialization/ApiProblem/ApiProblemMappingTest.php +++ /dev/null @@ -1,88 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new class() extends AbstractApiProblemMapping { - public function getClass(): string - { - return \stdClass::class; - } - }; - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new class() extends AbstractApiProblemMapping { - public function getClass(): string - { - return \stdClass::class; - } - }; - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new class() extends AbstractApiProblemMapping { - public function getClass(): string - { - return \stdClass::class; - } - }; - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new class() extends AbstractApiProblemMapping { - public function getClass(): string - { - return \stdClass::class; - } - }; - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/BadRequestMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/BadRequestMappingTest.php deleted file mode 100644 index ab36d4a..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/BadRequestMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new BadRequestMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new BadRequestMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('invalidParameters')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new BadRequestMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new BadRequestMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/ConflictMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/ConflictMappingTest.php deleted file mode 100644 index 3aa1cce..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/ConflictMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new ConflictMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new ConflictMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new ConflictMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new ConflictMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/ExpectationFailedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/ExpectationFailedMappingTest.php deleted file mode 100644 index 08bfcf3..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/ExpectationFailedMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new ExpectationFailedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new ExpectationFailedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('failedExpectations')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new ExpectationFailedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new ExpectationFailedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/FailedDependencyMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/FailedDependencyMappingTest.php deleted file mode 100644 index 277ec96..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/FailedDependencyMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new FailedDependencyMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new FailedDependencyMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new FailedDependencyMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new FailedDependencyMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/ForbiddenMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/ForbiddenMappingTest.php deleted file mode 100644 index 7afb1e4..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/ForbiddenMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new ForbiddenMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new ForbiddenMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new ForbiddenMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new ForbiddenMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/GoneMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/GoneMappingTest.php deleted file mode 100644 index 2315916..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/GoneMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new GoneMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new GoneMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new GoneMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new GoneMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/LengthRequiredMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/LengthRequiredMappingTest.php deleted file mode 100644 index 4d44bff..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/LengthRequiredMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new LengthRequiredMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new LengthRequiredMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new LengthRequiredMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new LengthRequiredMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/LockedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/LockedMappingTest.php deleted file mode 100644 index 5eefc28..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/LockedMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new LockedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new LockedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new LockedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new LockedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/MethodNotAllowedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/MethodNotAllowedMappingTest.php deleted file mode 100644 index 64271b7..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/MethodNotAllowedMappingTest.php +++ /dev/null @@ -1,66 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new MethodNotAllowedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new MethodNotAllowedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('method')->getMapping(), - NormalizationFieldMappingBuilder::create('allowedMethods')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new MethodNotAllowedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new MethodNotAllowedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/NotAcceptableMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/NotAcceptableMappingTest.php deleted file mode 100644 index e86ed19..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/NotAcceptableMappingTest.php +++ /dev/null @@ -1,66 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new NotAcceptableMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new NotAcceptableMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('accept')->getMapping(), - NormalizationFieldMappingBuilder::create('acceptables')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new NotAcceptableMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new NotAcceptableMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/NotFoundMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/NotFoundMappingTest.php deleted file mode 100644 index 7e0a475..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/NotFoundMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new NotFoundMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new NotFoundMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new NotFoundMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new NotFoundMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/PaymentRequiredMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/PaymentRequiredMappingTest.php deleted file mode 100644 index ee9f376..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/PaymentRequiredMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new PaymentRequiredMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new PaymentRequiredMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('paymentTypes')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new PaymentRequiredMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new PaymentRequiredMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/PreconditionFailedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/PreconditionFailedMappingTest.php deleted file mode 100644 index b4fc13f..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/PreconditionFailedMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new PreconditionFailedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new PreconditionFailedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('failedPreconditions')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new PreconditionFailedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new PreconditionFailedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMappingTest.php deleted file mode 100644 index d0a3ab3..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/ProxyAuthenticationRequiredMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new ProxyAuthenticationRequiredMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new ProxyAuthenticationRequiredMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new ProxyAuthenticationRequiredMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new ProxyAuthenticationRequiredMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/RequestEntityTooLargeMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/RequestEntityTooLargeMappingTest.php deleted file mode 100644 index 7308665..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/RequestEntityTooLargeMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new RequestEntityTooLargeMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new RequestEntityTooLargeMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('maxContentLength')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new RequestEntityTooLargeMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new RequestEntityTooLargeMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/RequestTimeoutMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/RequestTimeoutMappingTest.php deleted file mode 100644 index a18b212..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/RequestTimeoutMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new RequestTimeoutMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new RequestTimeoutMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new RequestTimeoutMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new RequestTimeoutMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/RequestUriTooLongMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/RequestUriTooLongMappingTest.php deleted file mode 100644 index 44b9b5e..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/RequestUriTooLongMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new RequestUriTooLongMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new RequestUriTooLongMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('maxUriLength')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new RequestUriTooLongMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new RequestUriTooLongMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMappingTest.php deleted file mode 100644 index cc58c56..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/RequestedRangeNotSatisfiableMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new RequestedRangeNotSatisfiableMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new RequestedRangeNotSatisfiableMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new RequestedRangeNotSatisfiableMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new RequestedRangeNotSatisfiableMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/UnauthorizedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/UnauthorizedMappingTest.php deleted file mode 100644 index b1fd8f8..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/UnauthorizedMappingTest.php +++ /dev/null @@ -1,66 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new UnauthorizedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new UnauthorizedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('authorization')->getMapping(), - NormalizationFieldMappingBuilder::create('authorizationTypes')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new UnauthorizedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new UnauthorizedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/UnprocessableEntityMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/UnprocessableEntityMappingTest.php deleted file mode 100644 index a2f67bc..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/UnprocessableEntityMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new UnprocessableEntityMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new UnprocessableEntityMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('invalidParameters')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new UnprocessableEntityMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new UnprocessableEntityMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMappingTest.php b/tests/Unit/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMappingTest.php deleted file mode 100644 index db7c71f..0000000 --- a/tests/Unit/Serialization/ApiProblem/ClientError/UnsupportedMediaTypeMappingTest.php +++ /dev/null @@ -1,66 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new UnsupportedMediaTypeMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new UnsupportedMediaTypeMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('mediaType')->getMapping(), - NormalizationFieldMappingBuilder::create('supportedMediaTypes')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new UnsupportedMediaTypeMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new UnsupportedMediaTypeMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/BadGatewayMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/BadGatewayMappingTest.php deleted file mode 100644 index 8a45c1f..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/BadGatewayMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new BadGatewayMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new BadGatewayMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new BadGatewayMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new BadGatewayMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/GatewayTimeoutMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/GatewayTimeoutMappingTest.php deleted file mode 100644 index 9a0726a..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/GatewayTimeoutMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new GatewayTimeoutMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new GatewayTimeoutMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new GatewayTimeoutMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new GatewayTimeoutMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/HttpVersionNotSupportedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/HttpVersionNotSupportedMappingTest.php deleted file mode 100644 index 6a054e1..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/HttpVersionNotSupportedMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new HttpVersionNotSupportedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new HttpVersionNotSupportedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new HttpVersionNotSupportedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new HttpVersionNotSupportedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/InsufficientStorageMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/InsufficientStorageMappingTest.php deleted file mode 100644 index 079fe32..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/InsufficientStorageMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new InsufficientStorageMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new InsufficientStorageMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new InsufficientStorageMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new InsufficientStorageMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/InternalServerErrorMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/InternalServerErrorMappingTest.php deleted file mode 100644 index be1ae84..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/InternalServerErrorMappingTest.php +++ /dev/null @@ -1,65 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new InternalServerErrorMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new InternalServerErrorMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - NormalizationFieldMappingBuilder::create('backtrace')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new InternalServerErrorMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new InternalServerErrorMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/NotImplementedMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/NotImplementedMappingTest.php deleted file mode 100644 index 30d910b..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/NotImplementedMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new NotImplementedMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new NotImplementedMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new NotImplementedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new NotImplementedMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/Serialization/ApiProblem/ServerError/ServiceUnavailableMappingTest.php b/tests/Unit/Serialization/ApiProblem/ServerError/ServiceUnavailableMappingTest.php deleted file mode 100644 index ee9c260..0000000 --- a/tests/Unit/Serialization/ApiProblem/ServerError/ServiceUnavailableMappingTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getClass()); - } - - public function testGetNormalizationType(): void - { - $mapping = new ServiceUnavailableMapping(); - - self::assertSame('apiProblem', $mapping->getNormalizationType()); - } - - public function testGetNormalizationFieldMappings(): void - { - $mapping = new ServiceUnavailableMapping(); - - $fieldMappings = $mapping->getNormalizationFieldMappings('/'); - - self::assertEquals([ - NormalizationFieldMappingBuilder::create('type')->getMapping(), - NormalizationFieldMappingBuilder::create('title')->getMapping(), - NormalizationFieldMappingBuilder::create('detail')->getMapping(), - NormalizationFieldMappingBuilder::create('instance')->getMapping(), - ], $fieldMappings); - } - - public function testGetNormalizationEmbeddedFieldMappings(): void - { - $mapping = new ServiceUnavailableMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationEmbeddedFieldMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } - - public function testGetNormalizationLinkMappings(): void - { - $mapping = new ServiceUnavailableMapping(); - - $embeddedFieldMappings = $mapping->getNormalizationLinkMappings('/'); - - self::assertEquals([], $embeddedFieldMappings); - } -} diff --git a/tests/Unit/ServiceProvider/ApiHttpServiceProviderTest.php b/tests/Unit/ServiceProvider/ApiHttpServiceProviderTest.php deleted file mode 100644 index a52b41b..0000000 --- a/tests/Unit/ServiceProvider/ApiHttpServiceProviderTest.php +++ /dev/null @@ -1,56 +0,0 @@ -getMockByCalls(ResponseFactoryInterface::class); - - $container = new Container(); - $container->register(new ApiHttpServiceProvider()); - $container->register(new DeserializationServiceProvider()); - $container->register(new SerializationServiceProvider()); - - $container['api-http.response.factory'] = static fn () => $responseFactory; - - self::assertTrue(isset($container['api-http.response.manager'])); - self::assertTrue(isset($container['api-http.response.factory'])); - - self::assertInstanceOf(RequestManager::class, $container['api-http.request.manager']); - self::assertInstanceOf(ResponseManager::class, $container['api-http.response.manager']); - self::assertSame($responseFactory, $container['api-http.response.factory']); - } - - public function testFactoryExpectException(): void - { - self::expectException(\RuntimeException::class); - self::expectExceptionMessage('Missing response factory, define service "api-http.response.factory"'); - - $container = new Container(); - $container->register(new ApiHttpServiceProvider()); - - $container['api-http.response.factory']; - } -}