From 00e983242a364762ebc05694045db03d44f1b6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20HULARD?= Date: Wed, 12 Jun 2024 16:19:26 +0200 Subject: [PATCH 1/3] chore: Update composer to v2.7.7. --- .phive/phars.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 01916fc..20ad287 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,5 @@ - + From c667c2955cfdbabd1dfc6572b02dc6110a2a53ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20HULARD?= Date: Wed, 12 Jun 2024 16:20:04 +0200 Subject: [PATCH 2/3] deps: Move to devizzent/cebe-php-openapi. We need an up to date OpenAPI parser that is able to work with v3.1 specs. Work on #25 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 72de117..240f5c4 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ ], "require": { "php": "^8.1.0", - "league/openapi-psr7-validator": "^0.17|^0.18", - "cebe/php-openapi": "^1.7", + "league/openapi-psr7-validator": "0.*", + "devizzent/cebe-php-openapi": "^1.0", "psr/http-message": "^1.0", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", From f1efe0fff345d90767175e042c58f8d77c800fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20HULARD?= Date: Wed, 12 Jun 2024 16:32:29 +0200 Subject: [PATCH 3/3] chore: Use `self::` instead of `static::` inside tests. This was a change from php-cs-fixer. --- .../InvalidOpenApiDefinitionExceptionTest.php | 4 +- .../ValidationExceptionMapperTest.php | 18 +-- .../LeagueOpenAPIValidation/FactoryTest.php | 24 +-- .../RequestValidatorTest.php | 142 +++++++++--------- .../ResponseValidatorTest.php | 42 +++--- tests/unit/ExecutorTest.php | 18 +-- tests/unit/Http/Factory/HeadersTest.php | 28 ++-- .../Http/Factory/RequestBodyResolverTest.php | 10 +- .../unit/Http/Factory/RequestFactoryTest.php | 38 ++--- .../RequestUriParametersResolverTest.php | 10 +- .../Resolver/ArrayValueResolverTest.php | 6 +- .../Resolver/FakerValueResolverTest.php | 30 ++-- .../Resolver/PassThroughValueResolverTest.php | 10 +- tests/unit/Http/Factory/UriTest.php | 14 +- tests/unit/LoggedErrorExecutorTest.php | 12 +- .../Exception/ApiSchemaExceptionTest.php | 4 +- .../Exception/DataSchemaExceptionTest.php | 8 +- .../Exception/GenericExceptionTest.php | 6 +- .../OperationNotFoundExceptionTest.php | 10 +- .../ResponseNotExpectedExceptionTest.php | 14 +- .../Expectation/ExpectationCollectionTest.php | 4 +- .../Expectation/ExpectationFactoryTest.php | 12 +- .../ExpectationFailedExceptionTest.php | 4 +- .../Validator/Expectation/StatusCodeTest.php | 12 +- .../Validator/LoggedRequestValidatorTest.php | 12 +- .../Validator/LoggedResponseValidatorTest.php | 10 +- 26 files changed, 251 insertions(+), 251 deletions(-) diff --git a/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/InvalidOpenApiDefinitionExceptionTest.php b/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/InvalidOpenApiDefinitionExceptionTest.php index a21afe9..9a3f350 100644 --- a/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/InvalidOpenApiDefinitionExceptionTest.php +++ b/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/InvalidOpenApiDefinitionExceptionTest.php @@ -15,7 +15,7 @@ public function testItCanBeBuilt(): void { $exception = new InvalidOpenApiDefinitionException(new Exception()); - static::assertInstanceOf(InvalidArgumentException::class, $exception); - static::assertStringContainsString('The given OpenApi definition can\'t be loaded', $exception->getMessage()); + self::assertInstanceOf(InvalidArgumentException::class, $exception); + self::assertStringContainsString('The given OpenApi definition can\'t be loaded', $exception->getMessage()); } } diff --git a/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/ValidationExceptionMapperTest.php b/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/ValidationExceptionMapperTest.php index c78a60f..23f027e 100644 --- a/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/ValidationExceptionMapperTest.php +++ b/tests/unit/Bridge/LeagueOpenAPIValidation/Exception/ValidationExceptionMapperTest.php @@ -33,7 +33,7 @@ public function testItDoesntMapUnknownException(): void ) ); - static::assertNull( + self::assertNull( (new ValidationExceptionMapper())->map($exceptionChain) ); } @@ -53,9 +53,9 @@ public function testItMapsSchemaMismatchException(): void $mapped = (new ValidationExceptionMapper())->map($exceptionChain); - static::assertInstanceOf(DataSchemaException::class, $mapped); - static::assertSame('a.b', $mapped->path); - static::assertSame($error, $mapped->getPrevious()); + self::assertInstanceOf(DataSchemaException::class, $mapped); + self::assertSame('a.b', $mapped->path); + self::assertSame($error, $mapped->getPrevious()); } public function testItMapsInvalidSchema(): void @@ -72,8 +72,8 @@ public function testItMapsInvalidSchema(): void $mapped = (new ValidationExceptionMapper())->map($exceptionChain); - static::assertInstanceOf(ApiSchemaException::class, $mapped); - static::assertSame($error, $mapped->getPrevious()); + self::assertInstanceOf(ApiSchemaException::class, $mapped); + self::assertSame($error, $mapped->getPrevious()); } public function testItMapsValidationFailed(): void @@ -90,7 +90,7 @@ public function testItMapsValidationFailed(): void $mapped = (new ValidationExceptionMapper())->map($exceptionChain); - static::assertInstanceOf(GenericException::class, $mapped); + self::assertInstanceOf(GenericException::class, $mapped); } public function testItMapsInvalidQueryArgs(): void @@ -113,7 +113,7 @@ public function testItMapsInvalidQueryArgs(): void $mapped = (new ValidationExceptionMapper())->map($exceptionChain); - static::assertInstanceOf(GenericException::class, $mapped); - static::assertSame($invalidQueryArgsError, $mapped->getPrevious()); + self::assertInstanceOf(GenericException::class, $mapped); + self::assertSame($invalidQueryArgsError, $mapped->getPrevious()); } } diff --git a/tests/unit/Bridge/LeagueOpenAPIValidation/FactoryTest.php b/tests/unit/Bridge/LeagueOpenAPIValidation/FactoryTest.php index 17aaf8a..f8ed4be 100644 --- a/tests/unit/Bridge/LeagueOpenAPIValidation/FactoryTest.php +++ b/tests/unit/Bridge/LeagueOpenAPIValidation/FactoryTest.php @@ -21,18 +21,18 @@ public function testItCanBuildValidators(): void { $leagueBuilder = $this->createMock(ValidatorBuilder::class); $leagueBuilder - ->expects(static::once()) + ->expects(self::once()) ->method('getRequestValidator') ->willReturn($this->createMock(PSR7RequestValidator::class)); $leagueBuilder - ->expects(static::once()) + ->expects(self::once()) ->method('getResponseValidator') ->willReturn($this->createMock(PSR7ResponseValidator::class)); $factory = new Factory($leagueBuilder); - static::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator()); - static::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator()); + self::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator()); + self::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator()); } public function testItCaptureErrorsDuringRequestValidatorCreation(): void @@ -41,7 +41,7 @@ public function testItCaptureErrorsDuringRequestValidatorCreation(): void $leagueBuilder = $this->createMock(ValidatorBuilder::class); $leagueBuilder - ->expects(static::once()) + ->expects(self::once()) ->method('getRequestValidator') ->willThrowException(new Exception('Anything happened there…')); @@ -54,7 +54,7 @@ public function testItCaptureErrorsDuringResponseValidatorCreation(): void $leagueBuilder = $this->createMock(ValidatorBuilder::class); $leagueBuilder - ->expects(static::once()) + ->expects(self::once()) ->method('getResponseValidator') ->willThrowException(new Exception('Anything happened there…')); @@ -71,14 +71,14 @@ public function testItCanBeBuiltFromYamlFile(): void YAML); if ($writeSuccess === false) { - static::markTestSkipped('Temp file wasn\'t written.'); + self::markTestSkipped('Temp file wasn\'t written.'); return; } $factory = Factory::fromYamlFile($file); - static::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator()); - static::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator()); + self::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator()); + self::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator()); } public function testItCanBeBuiltFromJsonFile(): void @@ -94,14 +94,14 @@ public function testItCanBeBuiltFromJsonFile(): void JSON); if ($writeSuccess === false) { - static::markTestSkipped('Temp file wasn\'t written.'); + self::markTestSkipped('Temp file wasn\'t written.'); return; } $factory = Factory::fromJsonFile($file); - static::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator()); - static::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator()); + self::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator()); + self::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator()); } public function testItCantBeBuiltFromInexistantJsonFile(): void diff --git a/tests/unit/Bridge/LeagueOpenAPIValidation/RequestValidatorTest.php b/tests/unit/Bridge/LeagueOpenAPIValidation/RequestValidatorTest.php index 2bdc7b8..c111acc 100644 --- a/tests/unit/Bridge/LeagueOpenAPIValidation/RequestValidatorTest.php +++ b/tests/unit/Bridge/LeagueOpenAPIValidation/RequestValidatorTest.php @@ -30,77 +30,77 @@ public function testItCanBeBuilt(): void new ValidationExceptionMapper() ); - static::assertInstanceOf(RequestValidatorInterface::class, $validator); + self::assertInstanceOf(RequestValidatorInterface::class, $validator); } - public function testItCanValidateRequest(): void - { - $requestValidator = $this->createMock(PSR7RequestValidator::class); - $request = $this->createMock(RequestInterface::class); - - $requestValidator - ->expects(static::once()) - ->method('validate') - ->with($request); - - (new RequestValidator( - $requestValidator, - new ValidationExceptionMapper() - ))->validate($request); - } - - public function testItCallsExceptionMapperOnThrowable(): void - { - $this->expectException(ApiSchemaException::class); - - $requestValidator = $this->createMock(PSR7RequestValidator::class); - $validationMapper = $this->createMock(ValidationExceptionMapper::class); - $request = $this->createMock(RequestInterface::class); - - $error = new Exception('Error'); - - $requestValidator - ->expects(static::once()) - ->method('validate') - ->with($request) - ->willThrowException($error); - - $validationMapper - ->expects(static::once()) - ->method('map') - ->with($error) - ->willReturn(new ApiSchemaException($error)); - - (new RequestValidator($requestValidator, $validationMapper))->validate($request); - } - - /** - * @dataProvider giveExceptions - */ - public function testItCanCatchExceptions(Throwable $error, string $exception): void - { - $this->expectException($exception); - - $requestValidator = $this->createMock(PSR7RequestValidator::class); - $request = $this->createMock(RequestInterface::class); - - $requestValidator - ->expects(static::once()) - ->method('validate') - ->with($request) - ->willThrowException($error); - - (new RequestValidator( - $requestValidator, - new ValidationExceptionMapper() - ))->validate($request); - } - - public function giveExceptions(): \Generator - { - yield [new NoOperation('Message'), OperationNotFoundException::class]; - yield [new NoPath('Message'), OperationNotFoundException::class]; - yield [new MultipleOperationsMismatchForRequest('Message'), OperationNotFoundException::class]; - yield [new RuntimeException('Message'), RuntimeException::class]; - } + public function testItCanValidateRequest(): void + { + $requestValidator = $this->createMock(PSR7RequestValidator::class); + $request = $this->createMock(RequestInterface::class); + + $requestValidator + ->expects(self::once()) + ->method('validate') + ->with($request); + + (new RequestValidator( + $requestValidator, + new ValidationExceptionMapper() + ))->validate($request); + } + + public function testItCallsExceptionMapperOnThrowable(): void + { + $this->expectException(ApiSchemaException::class); + + $requestValidator = $this->createMock(PSR7RequestValidator::class); + $validationMapper = $this->createMock(ValidationExceptionMapper::class); + $request = $this->createMock(RequestInterface::class); + + $error = new Exception('Error'); + + $requestValidator + ->expects(self::once()) + ->method('validate') + ->with($request) + ->willThrowException($error); + + $validationMapper + ->expects(self::once()) + ->method('map') + ->with($error) + ->willReturn(new ApiSchemaException($error)); + + (new RequestValidator($requestValidator, $validationMapper))->validate($request); + } + + /** + * @dataProvider provideItCanCatchExceptionsCases + */ + public function testItCanCatchExceptions(Throwable $error, string $exception): void + { + $this->expectException($exception); + + $requestValidator = $this->createMock(PSR7RequestValidator::class); + $request = $this->createMock(RequestInterface::class); + + $requestValidator + ->expects(self::once()) + ->method('validate') + ->with($request) + ->willThrowException($error); + + (new RequestValidator( + $requestValidator, + new ValidationExceptionMapper() + ))->validate($request); + } + + public static function provideItCanCatchExceptionsCases(): iterable + { + yield [new NoOperation('Message'), OperationNotFoundException::class]; + yield [new NoPath('Message'), OperationNotFoundException::class]; + yield [new MultipleOperationsMismatchForRequest('Message'), OperationNotFoundException::class]; + yield [new RuntimeException('Message'), RuntimeException::class]; + } } diff --git a/tests/unit/Bridge/LeagueOpenAPIValidation/ResponseValidatorTest.php b/tests/unit/Bridge/LeagueOpenAPIValidation/ResponseValidatorTest.php index d9e1caa..43781ad 100644 --- a/tests/unit/Bridge/LeagueOpenAPIValidation/ResponseValidatorTest.php +++ b/tests/unit/Bridge/LeagueOpenAPIValidation/ResponseValidatorTest.php @@ -38,7 +38,7 @@ public function testItCanBeBuilt(): void new ValidationExceptionMapper() ); - static::assertInstanceOf(ResponseValidatorInterface::class, $validator); + self::assertInstanceOf(ResponseValidatorInterface::class, $validator); } public function testItCanValidateResponse(): void @@ -46,10 +46,10 @@ public function testItCanValidateResponse(): void [, $request, $response, $responseValidator] = $this->prepare(); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with( - static::callback(fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), + self::callback(static fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), $response ); @@ -81,15 +81,15 @@ public function testItValidatesAgainstThePathThatMatchesTheBestTheCurrentRequest ); $uri - ->expects(static::atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('getPath') ->willReturn('/api/path'); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with( - static::callback(fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/api/path'), + self::callback(static fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/api/path'), $response ); @@ -123,11 +123,11 @@ public function testItFailsWhenNoOperationHaveBeenFoundThatMatchesTheCurrentRequ 'https://chstudio.fr/anotherpath' ); $uri - ->expects(static::never()) + ->expects(self::never()) ->method('getPath'); $responseValidator - ->expects(static::never()) + ->expects(self::never()) ->method('validate'); $validator = new ResponseValidator( @@ -146,10 +146,10 @@ public function testItFailsWhenNoResponseWasFoundThatMatchesStatusCode(): void [, $request, $response, $responseValidator] = $this->prepare(); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with( - static::callback(fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), + self::callback(static fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), $response ) ->willThrowException(new NoResponseCode('Error')); @@ -172,16 +172,16 @@ public function testItFailsWhenExceptionThrownDuringValidation(): void $mapper = $this->createMock(ValidationExceptionMapper::class); $mapper - ->expects(static::once()) + ->expects(self::once()) ->method('map') ->with($error) ->willReturn(new GenericException($error)); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with( - static::callback(fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), + self::callback(static fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), $response ) ->willThrowException($error); @@ -198,10 +198,10 @@ public function testItThrowsTheExceptionIfItCantBeMapped(): void [, $request, $response, $responseValidator] = $this->prepare(); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with( - static::callback(fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), + self::callback(static fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), $response ) ->willThrowException(new InvalidArgumentException('Message')); @@ -228,10 +228,10 @@ public function testItCapturesSpecificSpecFinderErrorsFromLeagueLibraryAsRespons $property->setValue($specFinderError, '/a/path/to/SpecFinder.php'); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with( - static::callback(fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), + self::callback(static fn (OperationAddress $op) => $op->method() === 'get' && $op->path() === '/'), $response ) ->willThrowException($specFinderError); @@ -259,23 +259,23 @@ private function prepare(OpenApi $openApi = null, string $uriString = null): arr $uri = $this->createMock(UriInterface::class); $uri - ->expects(static::atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('__toString') ->willReturn($uriString ?? 'https://chstudio.fr/'); $request = $this->createMock(RequestInterface::class); $request - ->expects(static::atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('getUri') ->willReturn($uri); $request - ->expects(static::atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('getMethod') ->willReturn('GET'); $response = $this->createMock(ResponseInterface::class); $responseValidator = $this->createMock(PSR7ResponseValidator::class); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('getSchema') ->willReturn($openApi); diff --git a/tests/unit/ExecutorTest.php b/tests/unit/ExecutorTest.php index ff90623..188a5a0 100644 --- a/tests/unit/ExecutorTest.php +++ b/tests/unit/ExecutorTest.php @@ -26,7 +26,7 @@ public function testCanBeBuilt(): void $this->createMock(ResponseValidatorInterface::class), ); - static::assertInstanceOf(ExecutorInterface::class, $executor); + self::assertInstanceOf(ExecutorInterface::class, $executor); } public function testCanExecuteARequest(): void @@ -39,22 +39,22 @@ public function testCanExecuteARequest(): void $expectation = $this->createMock(ResponseExpectationInterface::class); $httpClient - ->expects(static::once()) + ->expects(self::once()) ->method('sendRequest') ->with($request) ->willReturn($response); $requestValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with($request); $responseValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with($response); $expectation - ->expects(static::once()) + ->expects(self::once()) ->method('verify') ->with($response) ->willReturn(null); @@ -75,21 +75,21 @@ public function testBreaksIfExpectationFails(): void $expectation = $this->createMock(ResponseExpectationInterface::class); $httpClient - ->expects(static::once()) + ->expects(self::once()) ->method('sendRequest') ->with($request) ->willReturn($response); $requestValidator - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with($request); $responseValidator - ->expects(static::never()) + ->expects(self::never()) ->method('validate'); $expectation - ->expects(static::once()) + ->expects(self::once()) ->method('verify') ->with($response) ->willReturn(new ExpectationFailedException('Error', $expectation)); diff --git a/tests/unit/Http/Factory/HeadersTest.php b/tests/unit/Http/Factory/HeadersTest.php index db58da5..a175d63 100644 --- a/tests/unit/Http/Factory/HeadersTest.php +++ b/tests/unit/Http/Factory/HeadersTest.php @@ -15,8 +15,8 @@ final class HeadersTest extends TestCase public function testItCanBeBuiltFromString(): void { $uri = new Headers([]); - static::assertInstanceOf(Stringable::class, $uri); - static::assertInstanceOf(IteratorAggregate::class, $uri); + self::assertInstanceOf(Stringable::class, $uri); + self::assertInstanceOf(IteratorAggregate::class, $uri); } public function testItFailsOnNonArrayParameter(): void @@ -30,27 +30,27 @@ public function testItCanBeFilledAndChecked(): void { $headers = new Headers(['Content-Type' => 'application/json']); - static::assertTrue($headers->has('Content-Type')); - static::assertTrue($headers->has('content-type')); - static::assertTrue($headers->has('content-Type')); + self::assertTrue($headers->has('Content-Type')); + self::assertTrue($headers->has('content-type')); + self::assertTrue($headers->has('content-Type')); $expected = ['application/json']; - static::assertSame($expected, $headers->get('Content-Type')); - static::assertSame($expected, $headers->get('content-type')); - static::assertSame($expected, $headers->get('content-Type')); - static::assertSame('application/json', $headers->first('content-Type')); + self::assertSame($expected, $headers->get('Content-Type')); + self::assertSame($expected, $headers->get('content-type')); + self::assertSame($expected, $headers->get('content-Type')); + self::assertSame('application/json', $headers->first('content-Type')); - static::assertSame([], $headers->get('Non-Existing-Header')); + self::assertSame([], $headers->get('Non-Existing-Header')); $headers->set('content-type', 'other/type'); - static::assertSame(['application/json', 'other/type'], $headers->get('Content-Type')); + self::assertSame(['application/json', 'other/type'], $headers->get('Content-Type')); $iterator = iterator_to_array($headers); - static::assertArrayHasKey('content-type', $iterator); - static::assertSame(['application/json', 'other/type'], $iterator['content-type']); + self::assertArrayHasKey('content-type', $iterator); + self::assertSame(['application/json', 'other/type'], $iterator['content-type']); } public function testItCanBeSerializedToString(): void @@ -60,7 +60,7 @@ public function testItCanBeSerializedToString(): void 'A' => ['B', 'C'] ]); - static::assertSame( + self::assertSame( <<createMock(RequestFactoryInterface::class); $bodyResolver - ->expects(static::once()) + ->expects(self::once()) ->method('resolve') ->with(['a' => 'b']) ->willReturn(['c']); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('fromArray') ->with(['body' => ['c']]) ->willReturn($this->createMock(RequestInterface::class)); @@ -48,10 +48,10 @@ public function testItDoesntCallResolverOnEmptyBody(): void $bodyResolver = $this->createMock(ValueResolverInterface::class); $decorated = $this->createMock(RequestFactoryInterface::class); - $bodyResolver->expects(static::never())->method('resolve'); + $bodyResolver->expects(self::never())->method('resolve'); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('fromArray') ->with([]) ->willReturn($this->createMock(RequestInterface::class)); diff --git a/tests/unit/Http/Factory/RequestFactoryTest.php b/tests/unit/Http/Factory/RequestFactoryTest.php index ee41bb2..b82b7c3 100644 --- a/tests/unit/Http/Factory/RequestFactoryTest.php +++ b/tests/unit/Http/Factory/RequestFactoryTest.php @@ -23,7 +23,7 @@ public function testItCanBeBuilt(): void $factory = new RequestFactory($requestFactory, $streamFactory); - static::assertInstanceOf(RequestFactoryInterface::class, $factory); + self::assertInstanceOf(RequestFactoryInterface::class, $factory); } public function testItThrowsExceptionWhenUriIsNotPresent(): void @@ -51,24 +51,24 @@ public function testItBuildRequestFromArray(): void $bodyStream = $this->createMock(StreamInterface::class); $requestFactory - ->expects(static::once()) + ->expects(self::once()) ->method('createRequest') ->with('POST', 'https://chstudio.fr') ->willReturn($request); $request - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('withHeader') ->withConsecutive(... $this->denormalizeHeaders($headers)) ->willReturn($request); $request - ->expects(static::once()) + ->expects(self::once()) ->method('withBody') ->with($bodyStream) ->willReturn($request); $streamFactory - ->expects(static::once()) + ->expects(self::once()) ->method('createStream') ->with(json_encode($body)) ->willReturn($bodyStream); @@ -81,7 +81,7 @@ public function testItBuildRequestFromArray(): void 'body' => $body ]); - static::assertInstanceOf(RequestInterface::class, $request); + self::assertInstanceOf(RequestInterface::class, $request); } public function testItBuildRequestFromArrayWithoutBody(): void @@ -91,27 +91,27 @@ public function testItBuildRequestFromArrayWithoutBody(): void $request = $this->createMock(RequestInterface::class); $requestFactory - ->expects(static::once()) + ->expects(self::once()) ->method('createRequest') ->with('GET', 'https://chstudio.fr') ->willReturn($request); - $request->expects(static::never())->method('withHeader'); - $request->expects(static::never())->method('withBody'); + $request->expects(self::never())->method('withHeader'); + $request->expects(self::never())->method('withBody'); - $streamFactory->expects(static::never())->method('createStream'); + $streamFactory->expects(self::never())->method('createStream'); $request = (new RequestFactory($requestFactory, $streamFactory)) ->fromArray([ 'uri' => 'https://chstudio.fr' ]); - static::assertInstanceOf(RequestInterface::class, $request); + self::assertInstanceOf(RequestInterface::class, $request); } /** * - * @dataProvider givesHeadersAndBody + * @dataProvider provideItBuildRequestFromArrayWithFormDataBodyCases */ public function testItBuildRequestFromArrayWithFormDataBody($body, $headers, $bodyAsString): void { @@ -121,30 +121,30 @@ public function testItBuildRequestFromArrayWithFormDataBody($body, $headers, $bo $bodyStream = $this->createMock(StreamInterface::class); $requestFactory - ->expects(static::once()) + ->expects(self::once()) ->method('createRequest') ->with('POST', 'https://chstudio.fr') ->willReturn($request); if ((is_countable($headers) ? \count($headers) : 0) > 0) { $request - ->expects(static::exactly(1)) + ->expects(self::exactly(1)) ->method('withHeader') ->withConsecutive(... $this->denormalizeHeaders($headers)) ->willReturn($request); } else { $request - ->expects(static::never()) + ->expects(self::never()) ->method('withHeader'); } $request - ->expects(static::once()) + ->expects(self::once()) ->method('withBody') ->with($bodyStream) ->willReturn($request); $streamFactory - ->expects(static::once()) + ->expects(self::once()) ->method('createStream') ->with($bodyAsString) ->willReturn($bodyStream); @@ -157,10 +157,10 @@ public function testItBuildRequestFromArrayWithFormDataBody($body, $headers, $bo 'body' => $body ]); - static::assertInstanceOf(RequestInterface::class, $request); + self::assertInstanceOf(RequestInterface::class, $request); } - public function givesHeadersAndBody(): \Generator + public static function provideItBuildRequestFromArrayWithFormDataBodyCases(): iterable { $body = ['a' => 'b', 'c' => true]; diff --git a/tests/unit/Http/Factory/RequestUriParametersResolverTest.php b/tests/unit/Http/Factory/RequestUriParametersResolverTest.php index d138a4e..b10647b 100644 --- a/tests/unit/Http/Factory/RequestUriParametersResolverTest.php +++ b/tests/unit/Http/Factory/RequestUriParametersResolverTest.php @@ -19,7 +19,7 @@ public function testItCanBeBuilt(): void $factory = new RequestUriParametersResolver($bodyResolver, $decorated); - static::assertInstanceOf(RequestFactoryInterface::class, $factory); + self::assertInstanceOf(RequestFactoryInterface::class, $factory); } public function testItResolvesUriParametersWhenThereIsOne(): void @@ -28,13 +28,13 @@ public function testItResolvesUriParametersWhenThereIsOne(): void $decorated = $this->createMock(RequestFactoryInterface::class); $bodyResolver - ->expects(static::once()) + ->expects(self::once()) ->method('resolve') ->with(['a' => 'b']) ->willReturn(['c']); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('fromArray') ->with(['uri' => ['parameters' => ['c']]]) ->willReturn($this->createMock(RequestInterface::class)); @@ -48,10 +48,10 @@ public function testItDoesntCallResolverOnEmptyParameters(): void $bodyResolver = $this->createMock(ValueResolverInterface::class); $decorated = $this->createMock(RequestFactoryInterface::class); - $bodyResolver->expects(static::never())->method('resolve'); + $bodyResolver->expects(self::never())->method('resolve'); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('fromArray') ->with([]) ->willReturn($this->createMock(RequestInterface::class)); diff --git a/tests/unit/Http/Factory/Resolver/ArrayValueResolverTest.php b/tests/unit/Http/Factory/Resolver/ArrayValueResolverTest.php index 3b8eafd..943e253 100644 --- a/tests/unit/Http/Factory/Resolver/ArrayValueResolverTest.php +++ b/tests/unit/Http/Factory/Resolver/ArrayValueResolverTest.php @@ -15,7 +15,7 @@ public function testItCanBeBuilt(): void $decorated = $this->createMock(ValueResolverInterface::class); $arrayResolver = new ArrayValueResolver($decorated); - static::assertInstanceOf(ValueResolverInterface::class, $arrayResolver); + self::assertInstanceOf(ValueResolverInterface::class, $arrayResolver); } public function testItResolveEachInnerArrayRecursively(): void @@ -32,7 +32,7 @@ public function testItResolveEachInnerArrayRecursively(): void $decorated = $this->createMock(ValueResolverInterface::class); $decorated - ->expects(static::exactly(3)) + ->expects(self::exactly(3)) ->method('resolve') ->withConsecutive( ['b'], @@ -43,7 +43,7 @@ public function testItResolveEachInnerArrayRecursively(): void $arrayResolver = new ArrayValueResolver($decorated); - static::assertSame( + self::assertSame( [ 'a' => 'updated', 'c' => [ diff --git a/tests/unit/Http/Factory/Resolver/FakerValueResolverTest.php b/tests/unit/Http/Factory/Resolver/FakerValueResolverTest.php index 3d3f435..719dfd2 100644 --- a/tests/unit/Http/Factory/Resolver/FakerValueResolverTest.php +++ b/tests/unit/Http/Factory/Resolver/FakerValueResolverTest.php @@ -19,17 +19,17 @@ public function testItCanBeBuilt(): void $this->createMock(ValueResolverInterface::class) ); - static::assertInstanceOf(ValueResolverInterface::class, $resolver); + self::assertInstanceOf(ValueResolverInterface::class, $resolver); } /** - * @dataProvider giveNonResolvableValues + * @dataProvider provideItPassTheValueToNextResolverInDifferentCases */ public function testItPassTheValueToNextResolverInDifferent(mixed $parameter): void { $decorated = $this->createMock(ValueResolverInterface::class); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('resolve') ->with($parameter) ->willReturn($parameter); @@ -42,7 +42,7 @@ public function testItPassTheValueToNextResolverInDifferent(mixed $parameter): v $resolver->resolve($parameter); } - public function giveNonResolvableValues(): \Generator + public static function provideItPassTheValueToNextResolverInDifferentCases(): iterable { yield [null]; yield [true]; @@ -53,17 +53,17 @@ public function giveNonResolvableValues(): \Generator } /** - * @dataProvider giveResolvableValues + * @dataProvider provideItResolveTheValueThroughFakerGeneratorCases */ public function testItResolveTheValueThroughFakerGenerator(string $parameter, string $method, array $arguments): void { $decorated = $this->createMock(ValueResolverInterface::class); $decorated - ->expects(static::never()) + ->expects(self::never()) ->method('resolve'); $generator = $this->createStub(Generator::class); $generator - ->expects(static::once()) + ->expects(self::once()) ->method('__call') ->with($method, $arguments) ->willReturn('generatedValue'); @@ -73,10 +73,10 @@ public function testItResolveTheValueThroughFakerGenerator(string $parameter, st $decorated ); - static::assertSame('generatedValue', $resolver->resolve($parameter)); + self::assertSame('generatedValue', $resolver->resolve($parameter)); } - public function giveResolvableValues(): \Generator + public static function provideItResolveTheValueThroughFakerGeneratorCases(): iterable { yield ['', 'method', []]; yield ['', 'more_complexMethod', [true, false, 0]]; @@ -87,11 +87,11 @@ public function testItCaptureFakerInvalidArguments(): void { $decorated = $this->createMock(ValueResolverInterface::class); $decorated - ->expects(static::never()) + ->expects(self::never()) ->method('resolve'); $generator = $this->createStub(Generator::class); $generator - ->expects(static::once()) + ->expects(self::once()) ->method('__call') ->with('method', []) ->willThrowException(new \InvalidArgumentException('Error')); @@ -101,7 +101,7 @@ public function testItCaptureFakerInvalidArguments(): void $decorated ); - static::assertNull($resolver->resolve('')); + self::assertNull($resolver->resolve('')); } public function testItFailsOnFunctionArgumentThatCantBeJsonDecoded(): void @@ -111,11 +111,11 @@ public function testItFailsOnFunctionArgumentThatCantBeJsonDecoded(): void $decorated = $this->createMock(ValueResolverInterface::class); $decorated - ->expects(static::never()) + ->expects(self::never()) ->method('resolve'); $generator = $this->createStub(Generator::class); $generator - ->expects(static::never()) + ->expects(self::never()) ->method('__call'); $resolver = new FakerValueResolver( @@ -123,6 +123,6 @@ public function testItFailsOnFunctionArgumentThatCantBeJsonDecoded(): void $decorated ); - static::assertNull($resolver->resolve('')); + self::assertNull($resolver->resolve('')); } } diff --git a/tests/unit/Http/Factory/Resolver/PassThroughValueResolverTest.php b/tests/unit/Http/Factory/Resolver/PassThroughValueResolverTest.php index dbdfae7..2117d1e 100644 --- a/tests/unit/Http/Factory/Resolver/PassThroughValueResolverTest.php +++ b/tests/unit/Http/Factory/Resolver/PassThroughValueResolverTest.php @@ -14,16 +14,16 @@ public function testItCanBeBuilt(): void { $resolver = new PassThroughValueResolver(); - static::assertInstanceOf(ValueResolverInterface::class, $resolver); + self::assertInstanceOf(ValueResolverInterface::class, $resolver); } public function testItReturnGivenValue(): void { $resolver = new PassThroughValueResolver(); - static::assertNull($resolver->resolve(null)); - static::assertSame(0, $resolver->resolve(0)); - static::assertTrue($resolver->resolve(true)); - static::assertSame([], $resolver->resolve([])); + self::assertNull($resolver->resolve(null)); + self::assertSame(0, $resolver->resolve(0)); + self::assertTrue($resolver->resolve(true)); + self::assertSame([], $resolver->resolve([])); } } diff --git a/tests/unit/Http/Factory/UriTest.php b/tests/unit/Http/Factory/UriTest.php index 1954beb..c08061a 100644 --- a/tests/unit/Http/Factory/UriTest.php +++ b/tests/unit/Http/Factory/UriTest.php @@ -14,8 +14,8 @@ final class UriTest extends TestCase public function testItCanBeBuiltFromString(): void { $uri = new Uri('a string'); - static::assertInstanceOf(Stringable::class, $uri); - static::assertSame('a string', $uri->__toString()); + self::assertInstanceOf(Stringable::class, $uri); + self::assertSame('a string', $uri->__toString()); } public function testItFailsToBuildFromArrayWithoutBase(): void @@ -25,16 +25,16 @@ public function testItFailsToBuildFromArrayWithoutBase(): void } /** - * @dataProvider giveArrays + * @dataProvider provideItCanBeBuiltFromArrayCases * */ public function testItCanBeBuiltFromArray($array, $expected): void { $uri = new Uri($array); - static::assertSame($expected, $uri->__toString()); + self::assertSame($expected, $uri->__toString()); } - public function giveArrays(): \Generator + public static function provideItCanBeBuiltFromArrayCases(): iterable { yield [ [ @@ -62,7 +62,7 @@ public function giveArrays(): \Generator } /** - * @dataProvider giveInvalidValues + * @dataProvider provideItCantBeBuiltFromOtherValuesCases * */ public function testItCantBeBuiltFromOtherValues(): void @@ -72,7 +72,7 @@ public function testItCantBeBuiltFromOtherValues(): void new Uri(0); } - public function giveInvalidValues(): \Generator + public static function provideItCantBeBuiltFromOtherValuesCases(): iterable { yield [0]; yield [[]]; diff --git a/tests/unit/LoggedErrorExecutorTest.php b/tests/unit/LoggedErrorExecutorTest.php index 3385571..1ac4a18 100644 --- a/tests/unit/LoggedErrorExecutorTest.php +++ b/tests/unit/LoggedErrorExecutorTest.php @@ -21,7 +21,7 @@ public function testCanBeBuilt(): void $this->createMock(LoggerInterface::class) ); - static::assertInstanceOf(ExecutorInterface::class, $executor); + self::assertInstanceOf(ExecutorInterface::class, $executor); } public function testWillLoggerWillNotBeCalledWithoutException(): void @@ -32,11 +32,11 @@ public function testWillLoggerWillNotBeCalledWithoutException(): void $request = $this->createMock(RequestInterface::class); $executor - ->expects(static::once()) + ->expects(self::once()) ->method('execute') ->with($request, $expectations); $logger - ->expects(static::never()) + ->expects(self::never()) ->method('emergency'); (new LoggedErrorExecutor($executor, $logger)) @@ -53,14 +53,14 @@ public function testWillLogOnEncounteredException(): void $error = new GenericException(new \Exception('message')); $executor - ->expects(static::once()) + ->expects(self::once()) ->method('execute') ->with($request, $expectations) ->willThrowException($error); $logger - ->expects(static::once()) + ->expects(self::once()) ->method('emergency') - ->with(static::stringContains('message'), ['error' => $error]); + ->with(self::stringContains('message'), ['error' => $error]); (new LoggedErrorExecutor($executor, $logger)) ->execute($request, $expectations); diff --git a/tests/unit/Validator/Exception/ApiSchemaExceptionTest.php b/tests/unit/Validator/Exception/ApiSchemaExceptionTest.php index 3efdf93..caac134 100644 --- a/tests/unit/Validator/Exception/ApiSchemaExceptionTest.php +++ b/tests/unit/Validator/Exception/ApiSchemaExceptionTest.php @@ -15,7 +15,7 @@ public function testItCanBeBuilt(): void { $exception = new ApiSchemaException(new Exception('Error')); - static::assertInstanceOf(ValidationException::class, $exception); - static::assertStringContainsString('Error', $exception->getMessage()); + self::assertInstanceOf(ValidationException::class, $exception); + self::assertStringContainsString('Error', $exception->getMessage()); } } diff --git a/tests/unit/Validator/Exception/DataSchemaExceptionTest.php b/tests/unit/Validator/Exception/DataSchemaExceptionTest.php index 2b2825c..f01dd79 100644 --- a/tests/unit/Validator/Exception/DataSchemaExceptionTest.php +++ b/tests/unit/Validator/Exception/DataSchemaExceptionTest.php @@ -20,9 +20,9 @@ public function testItCanBeBuilt(): void new Exception('Error') ); - static::assertInstanceOf(ValidationException::class, $exception); - static::assertStringContainsString(var_export($value, true), $exception->getMessage()); - static::assertStringContainsString('p.a.th', $exception->getMessage()); - static::assertStringContainsString('Error', $exception->getMessage()); + self::assertInstanceOf(ValidationException::class, $exception); + self::assertStringContainsString(var_export($value, true), $exception->getMessage()); + self::assertStringContainsString('p.a.th', $exception->getMessage()); + self::assertStringContainsString('Error', $exception->getMessage()); } } diff --git a/tests/unit/Validator/Exception/GenericExceptionTest.php b/tests/unit/Validator/Exception/GenericExceptionTest.php index 70e962e..9f6f797 100644 --- a/tests/unit/Validator/Exception/GenericExceptionTest.php +++ b/tests/unit/Validator/Exception/GenericExceptionTest.php @@ -15,8 +15,8 @@ public function testItCanBeBuilt(): void { $exception = new GenericException(new Exception('Error')); - static::assertInstanceOf(ValidationException::class, $exception); - static::assertStringContainsString('Something went wrong:', $exception->getMessage()); - static::assertStringContainsString('Error', $exception->getMessage()); + self::assertInstanceOf(ValidationException::class, $exception); + self::assertStringContainsString('Something went wrong:', $exception->getMessage()); + self::assertStringContainsString('Error', $exception->getMessage()); } } diff --git a/tests/unit/Validator/Exception/OperationNotFoundExceptionTest.php b/tests/unit/Validator/Exception/OperationNotFoundExceptionTest.php index 8b2ce16..7302aca 100644 --- a/tests/unit/Validator/Exception/OperationNotFoundExceptionTest.php +++ b/tests/unit/Validator/Exception/OperationNotFoundExceptionTest.php @@ -17,23 +17,23 @@ public function testItCanBeBuilt(): void { $uri = $this->createMock(UriInterface::class); $uri - ->expects(static::once()) + ->expects(self::once()) ->method('__toString') ->willReturn('http://uri'); $request = $this->createMock(RequestInterface::class); $request - ->expects(static::once()) + ->expects(self::once()) ->method('getMethod') ->willReturn('GET'); $request - ->expects(static::once()) + ->expects(self::once()) ->method('getUri') ->willReturn($uri); $exception = new OperationNotFoundException($request, new Exception('Error')); - static::assertInstanceOf(ValidationException::class, $exception); - static::assertStringContainsString('[GET] http://uri', $exception->getMessage()); + self::assertInstanceOf(ValidationException::class, $exception); + self::assertStringContainsString('[GET] http://uri', $exception->getMessage()); } } diff --git a/tests/unit/Validator/Exception/ResponseNotExpectedExceptionTest.php b/tests/unit/Validator/Exception/ResponseNotExpectedExceptionTest.php index 042ec49..3ed1fdc 100644 --- a/tests/unit/Validator/Exception/ResponseNotExpectedExceptionTest.php +++ b/tests/unit/Validator/Exception/ResponseNotExpectedExceptionTest.php @@ -18,30 +18,30 @@ public function testItCanBeBuilt(): void { $uri = $this->createMock(UriInterface::class); $uri - ->expects(static::once()) + ->expects(self::once()) ->method('__toString') ->willReturn('http://uri'); $request = $this->createMock(RequestInterface::class); $request - ->expects(static::once()) + ->expects(self::once()) ->method('getMethod') ->willReturn('GET'); $request - ->expects(static::once()) + ->expects(self::once()) ->method('getUri') ->willReturn($uri); $response = $this->createMock(ResponseInterface::class); $response - ->expects(static::once()) + ->expects(self::once()) ->method('getStatusCode') ->willReturn(450); $exception = new ResponseNotExpectedException($request, $response, new Exception('Error')); - static::assertInstanceOf(ValidationException::class, $exception); - static::assertStringContainsString('[GET] http://uri', $exception->getMessage()); - static::assertStringContainsString('450', $exception->getMessage()); + self::assertInstanceOf(ValidationException::class, $exception); + self::assertStringContainsString('[GET] http://uri', $exception->getMessage()); + self::assertStringContainsString('450', $exception->getMessage()); } } diff --git a/tests/unit/Validator/Expectation/ExpectationCollectionTest.php b/tests/unit/Validator/Expectation/ExpectationCollectionTest.php index 01d7ade..c3817c1 100644 --- a/tests/unit/Validator/Expectation/ExpectationCollectionTest.php +++ b/tests/unit/Validator/Expectation/ExpectationCollectionTest.php @@ -16,9 +16,9 @@ public function testItCanBeBuilt(): void $expectation = $this->createMock(ResponseExpectationInterface::class); $collection = new ExpectationCollection($expectation); - static::assertInstanceOf(IteratorAggregate::class, $collection); + self::assertInstanceOf(IteratorAggregate::class, $collection); $iterator = $collection->getIterator(); - static::assertSame($expectation, $iterator->current()); + self::assertSame($expectation, $iterator->current()); } } diff --git a/tests/unit/Validator/Expectation/ExpectationFactoryTest.php b/tests/unit/Validator/Expectation/ExpectationFactoryTest.php index 48282c5..71789ee 100644 --- a/tests/unit/Validator/Expectation/ExpectationFactoryTest.php +++ b/tests/unit/Validator/Expectation/ExpectationFactoryTest.php @@ -16,11 +16,11 @@ public function testItBuildsExpectationFromArray(): void $collection = (new ExpectationFactory()) ->fromArray(['statusCode' => 201]); - static::assertInstanceOf(ExpectationCollection::class, $collection); + self::assertInstanceOf(ExpectationCollection::class, $collection); $expectations = iterator_to_array($collection); - static::assertCount(1, $expectations); - static::assertInstanceOf(StatusCode::class, $expectations[0]); - static::assertSame(201, $expectations[0]->statusCode); + self::assertCount(1, $expectations); + self::assertInstanceOf(StatusCode::class, $expectations[0]); + self::assertSame(201, $expectations[0]->statusCode); } public function testItReturnsAnEmptyCollectionWhenNoExpectationsCanBeBuilt(): void @@ -28,8 +28,8 @@ public function testItReturnsAnEmptyCollectionWhenNoExpectationsCanBeBuilt(): vo $collection = (new ExpectationFactory()) ->fromArray(['a' => true, 'b' => 'c']); - static::assertInstanceOf(ExpectationCollection::class, $collection); + self::assertInstanceOf(ExpectationCollection::class, $collection); $expectations = iterator_to_array($collection); - static::assertCount(0, $expectations); + self::assertCount(0, $expectations); } } diff --git a/tests/unit/Validator/Expectation/ExpectationFailedExceptionTest.php b/tests/unit/Validator/Expectation/ExpectationFailedExceptionTest.php index dbe7e0c..6a2a777 100644 --- a/tests/unit/Validator/Expectation/ExpectationFailedExceptionTest.php +++ b/tests/unit/Validator/Expectation/ExpectationFailedExceptionTest.php @@ -16,7 +16,7 @@ public function testItCanBeBuilt(): void $failedExpectation = $this->createMock(ResponseExpectationInterface::class); $exception = new ExpectationFailedException('message', $failedExpectation); - static::assertInstanceOf(RuntimeException::class, $exception); - static::assertSame($failedExpectation, $exception->expectation); + self::assertInstanceOf(RuntimeException::class, $exception); + self::assertSame($failedExpectation, $exception->expectation); } } diff --git a/tests/unit/Validator/Expectation/StatusCodeTest.php b/tests/unit/Validator/Expectation/StatusCodeTest.php index e66efb3..d8779f1 100644 --- a/tests/unit/Validator/Expectation/StatusCodeTest.php +++ b/tests/unit/Validator/Expectation/StatusCodeTest.php @@ -16,7 +16,7 @@ public function testItCanBeBuilt(): void { $expectation = new StatusCode(200); - static::assertInstanceOf(ResponseExpectationInterface::class, $expectation); + self::assertInstanceOf(ResponseExpectationInterface::class, $expectation); } public function testItVerifiesStatusCode(): void @@ -25,11 +25,11 @@ public function testItVerifiesStatusCode(): void $response = $this->createMock(ResponseInterface::class); $response - ->expects(static::once()) + ->expects(self::once()) ->method('getStatusCode') ->willReturn(200); - static::assertNull($expectation->verify($response)); + self::assertNull($expectation->verify($response)); } public function testItReturnsExceptionIfFailed(): void @@ -38,13 +38,13 @@ public function testItReturnsExceptionIfFailed(): void $response = $this->createMock(ResponseInterface::class); $response - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('getStatusCode') ->willReturn(200); $result = $expectation->verify($response); - static::assertInstanceOf(ExpectationFailedException::class, $result); - static::assertSame( + self::assertInstanceOf(ExpectationFailedException::class, $result); + self::assertSame( 'Unexpected status code 200, expected 400', $result->getMessage() ); diff --git a/tests/unit/Validator/LoggedRequestValidatorTest.php b/tests/unit/Validator/LoggedRequestValidatorTest.php index 612dc0e..2fe6f67 100644 --- a/tests/unit/Validator/LoggedRequestValidatorTest.php +++ b/tests/unit/Validator/LoggedRequestValidatorTest.php @@ -20,7 +20,7 @@ public function testItCanBeBuilt(): void $factory = new LoggedRequestValidator($logger, $decorated); - static::assertInstanceOf(RequestValidatorInterface::class, $factory); + self::assertInstanceOf(RequestValidatorInterface::class, $factory); } public function testItLogsRequestAtDebugLevel(): void @@ -31,20 +31,20 @@ public function testItLogsRequestAtDebugLevel(): void $logger = $this->createMock(LoggerInterface::class); $uri - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('__toString') ->willReturn('https://chstudio.fr'); $request - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('getMethod') ->willReturn('GET'); $request - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('getUri') ->willReturn($uri); $logger - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('debug') ->withConsecutive( ['Start testing Request: [GET] https://chstudio.fr'], @@ -52,7 +52,7 @@ public function testItLogsRequestAtDebugLevel(): void ); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with($request); diff --git a/tests/unit/Validator/LoggedResponseValidatorTest.php b/tests/unit/Validator/LoggedResponseValidatorTest.php index 8b01b51..21d3520 100644 --- a/tests/unit/Validator/LoggedResponseValidatorTest.php +++ b/tests/unit/Validator/LoggedResponseValidatorTest.php @@ -20,7 +20,7 @@ public function testItCanBeBuilt(): void $factory = new LoggedResponseValidator($logger, $decorated); - static::assertInstanceOf(ResponseValidatorInterface::class, $factory); + self::assertInstanceOf(ResponseValidatorInterface::class, $factory); } public function testItLogsRequestAtDebugLevel(): void @@ -31,16 +31,16 @@ public function testItLogsRequestAtDebugLevel(): void $logger = $this->createMock(LoggerInterface::class); $response - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('getStatusCode') ->willReturn(408); $response - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('getReasonPhrase') ->willReturn('I\'m not a teapost'); $logger - ->expects(static::exactly(2)) + ->expects(self::exactly(2)) ->method('debug') ->withConsecutive( ['Start testing Response: [408] I\'m not a teapost'], @@ -48,7 +48,7 @@ public function testItLogsRequestAtDebugLevel(): void ); $decorated - ->expects(static::once()) + ->expects(self::once()) ->method('validate') ->with($response, $request);