diff --git a/composer.json b/composer.json index a9e8409..6373703 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "fakerphp/faker": "^1.10", + "fakerphp/faker": "^1.15", "phpstan/phpstan": "^0.12.49", "http-interop/http-factory-guzzle": "^1.0", "squizlabs/php_codesniffer": "^3.5" diff --git a/tests/Action/ActionTraitTest.php b/tests/Action/ActionTraitTest.php index b385170..9c9abfe 100644 --- a/tests/Action/ActionTraitTest.php +++ b/tests/Action/ActionTraitTest.php @@ -46,9 +46,9 @@ public function testExecute(): void $this->requestFactory->expects(self::once())->method('createGetRequest')->with($uri) ->willReturn($request); - $filterKey = $this->faker()->slug; - $filterValue = $this->faker()->word; - if ($this->faker()->boolean) { + $filterKey = $this->faker()->slug(); + $filterValue = $this->faker()->word(); + if ($this->faker()->boolean()) { $this->request->filter($filterKey, $filterValue); } else { $this->request->filter([$filterKey => $filterValue]); @@ -58,9 +58,9 @@ public function testExecute(): void $request->expects(self::once())->method('filter')->willReturn($filterCollection); $filterCollection->expects(self::once())->method('set')->with($filterKey, $filterValue); - $paginationKey = $this->faker()->slug; + $paginationKey = $this->faker()->slug(); $paginationValue = $this->faker()->numberBetween(); - if ($this->faker()->boolean) { + if ($this->faker()->boolean()) { $this->request->pagination($paginationKey, $paginationValue); } else { $this->request->pagination([$paginationKey => $paginationValue]); @@ -69,9 +69,9 @@ public function testExecute(): void $request->expects(self::once())->method('pagination')->willReturn($paginationCollection); $paginationCollection->expects(self::once())->method('set')->with($paginationKey, $paginationValue); - $sortField = $this->faker()->slug; - $sortDirection = $this->faker()->slug; - if ($this->faker()->boolean) { + $sortField = $this->faker()->slug(); + $sortDirection = $this->faker()->slug(); + if ($this->faker()->boolean()) { $this->request->sort($sortField, $sortDirection); } else { $this->request->sort([$sortField => $sortDirection]); diff --git a/tests/Exception/ResponseValidationExceptionTest.php b/tests/Exception/ResponseValidationExceptionTest.php index f461bf6..c935f73 100644 --- a/tests/Exception/ResponseValidationExceptionTest.php +++ b/tests/Exception/ResponseValidationExceptionTest.php @@ -35,7 +35,7 @@ public function provideScenarios(): Generator ResponseValidationException::CODE_RESOURCE_MISSING ]; yield [ - ResponseValidationException::typeMismatch($response, $faker->slug, $faker->slug, $faker->numberBetween()), + ResponseValidationException::typeMismatch($response, $faker->slug(), $faker->slug(), $faker->numberBetween()), ResponseValidationException::CODE_TYPE_MISMATCH ]; yield [ diff --git a/tests/Factory/Oauth2/CredentialFactoryTest.php b/tests/Factory/Oauth2/CredentialFactoryTest.php index 7cc21cd..696fec6 100644 --- a/tests/Factory/Oauth2/CredentialFactoryTest.php +++ b/tests/Factory/Oauth2/CredentialFactoryTest.php @@ -20,8 +20,8 @@ public function testConversion(): void $response->method('getBody')->willReturn($stream); $responseData = [ - 'token_type' => $this->faker()->slug, - 'access_token' => $this->faker()->md5, + 'token_type' => $this->faker()->slug(), + 'access_token' => $this->faker()->md5(), 'expires_in' => $this->faker()->numberBetween(), ]; $stream->method('getContents')->willReturn(json_encode($responseData)); @@ -43,8 +43,8 @@ public function testInvalidExpirationInterval(): void $response->method('getBody')->willReturn($stream); $responseData = [ - 'token_type' => $this->faker()->slug, - 'access_token' => $this->faker()->md5, + 'token_type' => $this->faker()->slug(), + 'access_token' => $this->faker()->md5(), 'expires_in' => -1 * $this->faker()->numberBetween(), ]; $stream->method('getContents')->willReturn(json_encode($responseData)); @@ -88,7 +88,7 @@ public function testInvalidJson(): void $stream = $this->createMock(StreamInterface::class); $response->method('getBody')->willReturn($stream); - $stream->method('getContents')->willReturn($this->faker()->text); + $stream->method('getContents')->willReturn($this->faker()->text()); $this->expectExceptionObject(AuthenticationException::unableToDecodeResponse()->setResponse($response)); (new CredentialFactory())->fromAuthorityResponse($response); @@ -100,7 +100,7 @@ public function testErrorResponse(): void $stream = $this->createMock(StreamInterface::class); $response->method('getBody')->willReturn($stream); - $errorSlug = $this->faker()->slug; + $errorSlug = $this->faker()->slug(); $stream->method('getContents')->willReturn(json_encode(['error' => $errorSlug])); $this->expectExceptionObject(AuthenticationException::failed($errorSlug)->setResponse($response)); diff --git a/tests/Factory/RequestFactoryTest.php b/tests/Factory/RequestFactoryTest.php index 5a6e1ea..5e1b92a 100644 --- a/tests/Factory/RequestFactoryTest.php +++ b/tests/Factory/RequestFactoryTest.php @@ -14,7 +14,7 @@ class RequestFactoryTest extends TestCase protected function setUp(): void { - $this->baseUrl = 'http://' . $this->faker()->domainName . '/' . $this->faker()->slug; + $this->baseUrl = 'http://' . $this->faker()->domainName() . '/' . $this->faker()->slug(); $this->requestFactory = new RequestFactory(new Uri($this->baseUrl)); } @@ -26,8 +26,8 @@ public function providesRequestData(): array * [] * ] */ - $type = $this->faker()->word; - $relationshipType = $this->faker()->word; + $type = $this->faker()->word(); + $relationshipType = $this->faker()->word(); $id = $this->faker()->randomNumber(5); return [ [ #0 @@ -176,15 +176,15 @@ public function testCreateDeleteRequest(array $params, array $expected): void public function testWithUserInfo(): void { - $this->baseUrl = 'http://' . $this->faker()->domainName . '/' . $this->faker()->slug . '?foo2=bar2'; + $this->baseUrl = 'http://' . $this->faker()->domainName() . '/' . $this->faker()->slug() . '?foo2=bar2'; $this->requestFactory = new RequestFactory(new Uri($this->baseUrl)); - $user = $this->faker()->userName; - $pass = $this->faker()->userName; + $user = $this->faker()->userName(); + $pass = $this->faker()->userName(); - $type = $this->faker()->slug; + $type = $this->faker()->slug(); $id = (string) $this->faker()->numberBetween(); - $uri = sprintf('http://%s:%s@%s/%s/%s?foo=bar', $user, $pass, $this->faker()->domainName, $type, $id); + $uri = sprintf('http://%s:%s@%s/%s/%s?foo=bar', $user, $pass, $this->faker()->domainName(), $type, $id); $request = $this->requestFactory->createGetRequest(new Uri($uri), $type); $this->assertEquals($type, $request->type()); $this->assertEquals($id, $request->id()); diff --git a/tests/JsonApiClientTest.php b/tests/JsonApiClientTest.php index 6d2edcb..a5889ad 100644 --- a/tests/JsonApiClientTest.php +++ b/tests/JsonApiClientTest.php @@ -50,7 +50,7 @@ protected function setUp(): void public function testExecute(): void { $request = $this->createMock(RequestInterface::class); - $method = $this->faker()->slug; + $method = $this->faker()->slug(); $request->expects(self::once())->method('method')->willReturn($method); $uri = $this->createMock(UriInterface::class); @@ -61,8 +61,8 @@ public function testExecute(): void $httpRequest = $this->createMock(\Psr\Http\Message\RequestInterface::class); $this->requestFactory->method('createRequest')->with($method, $uri)->willReturn($httpRequest); - $headerKey = $this->faker()->slug; - $headerValue = $this->faker()->slug; + $headerKey = $this->faker()->slug(); + $headerValue = $this->faker()->slug(); $header = new KeyValueCollection([$headerKey => $headerValue]); $request->expects(self::once())->method('headers')->willReturn($header); @@ -71,7 +71,7 @@ public function testExecute(): void $document = $this->createMock(DocumentInterface::class); $request->expects(self::atLeastOnce())->method('document')->willReturn($document); - $data = [$this->faker()->text]; + $data = [$this->faker()->text()]; $this->serializer->method('serializeDocument')->with($document)->willReturn($data); $stream = $this->createMock(StreamInterface::class); @@ -100,7 +100,7 @@ public function testExecute(): void public function testFailedSerialization(): void { $request = $this->createMock(RequestInterface::class); - $method = $this->faker()->slug; + $method = $this->faker()->slug(); $request->expects(self::once())->method('method')->willReturn($method); $uri = $this->createMock(UriInterface::class); @@ -109,8 +109,8 @@ public function testFailedSerialization(): void $httpRequest = $this->createMock(\Psr\Http\Message\RequestInterface::class); $this->requestFactory->method('createRequest')->with($method, $uri)->willReturn($httpRequest); - $headerKey = $this->faker()->slug; - $headerValue = $this->faker()->slug; + $headerKey = $this->faker()->slug(); + $headerValue = $this->faker()->slug(); $header = new KeyValueCollection([$headerKey => $headerValue]); $request->expects(self::once())->method('headers')->willReturn($header); diff --git a/tests/Middleware/AuthenticationMiddlewareTest.php b/tests/Middleware/AuthenticationMiddlewareTest.php index f979488..adebc3b 100644 --- a/tests/Middleware/AuthenticationMiddlewareTest.php +++ b/tests/Middleware/AuthenticationMiddlewareTest.php @@ -31,9 +31,9 @@ protected function setUp(): void public function testOAuth2(): void { $oauth2Credentials = new OAuth2Credentials( - $this->faker()->slug, - $this->faker()->md5, - $this->faker()->dateTime + $this->faker()->slug(), + $this->faker()->md5(), + $this->faker()->dateTime() ); $this->authMiddleware->setOAuth2Credentials($oauth2Credentials); @@ -47,8 +47,8 @@ public function testOAuth2(): void public function testBasic(): void { $basicCredentials = new BasicCredentials( - $this->faker()->userName, - $this->faker()->password, + $this->faker()->userName(), + $this->faker()->password(), ); $this->authMiddleware->setBasicCredentials($basicCredentials); diff --git a/tests/Model/Auth2CredentialsTest.php b/tests/Model/Auth2CredentialsTest.php index a111ce1..efb8f1d 100644 --- a/tests/Model/Auth2CredentialsTest.php +++ b/tests/Model/Auth2CredentialsTest.php @@ -28,8 +28,8 @@ public function testIsExpired(): void private function createModel(?DateTimeInterface $dateTime): OAuth2Credentials { return new OAuth2Credentials( - $this->faker()->slug, - $this->faker()->md5, + $this->faker()->slug(), + $this->faker()->md5(), $dateTime ); } diff --git a/tests/Model/BasicCredentialsTest.php b/tests/Model/BasicCredentialsTest.php index 002f461..8efd471 100644 --- a/tests/Model/BasicCredentialsTest.php +++ b/tests/Model/BasicCredentialsTest.php @@ -9,8 +9,8 @@ class BasicCredentialsTest extends TestCase { public function test(): void { - $username = $this->faker()->userName; - $password = $this->faker()->password; + $username = $this->faker()->userName(); + $password = $this->faker()->password(); $credentials = new BasicCredentials($username, $password); $this->assertEquals($username, $credentials->username); diff --git a/tests/Response/ResponseFactoryTest.php b/tests/Response/ResponseFactoryTest.php index 64ab6de..22e9182 100644 --- a/tests/Response/ResponseFactoryTest.php +++ b/tests/Response/ResponseFactoryTest.php @@ -35,7 +35,7 @@ public function testCreateResponse(): void $stream = $this->createMock(StreamInterface::class); $psrResponse->expects(self::exactly(2))->method('getBody')->willReturn($stream); - $responseBody = [$this->faker()->text]; + $responseBody = [$this->faker()->text()]; $responseBodyEncoded = json_encode($responseBody); $stream->expects(self::once())->method('getContents')->willReturn($responseBodyEncoded); $stream->expects(self::once())->method('rewind'); @@ -43,7 +43,7 @@ public function testCreateResponse(): void $httpStatus = 200; $psrResponse->method('getStatusCode')->willReturn($httpStatus); $headers = [ - $this->faker()->word => $this->faker()->word, + $this->faker()->word() => $this->faker()->word(), ]; $psrResponse->method('getHeaders')->willReturn($headers); @@ -101,7 +101,7 @@ public function testCreateErrorResponseThrowsNoInvalidJson(): void $psrResponse->expects(self::exactly(2))->method('getBody')->willReturn($stream); $headers = [ - $this->faker()->word => $this->faker()->word, + $this->faker()->word() => $this->faker()->word(), ]; $psrResponse->method('getHeaders')->willReturn($headers); @@ -139,11 +139,11 @@ public function testCreateErrorResponseContainsValidJsonResponse(): void $psrResponse->expects(self::exactly(2))->method('getBody')->willReturn($stream); $headers = [ - $this->faker()->word => $this->faker()->word, + $this->faker()->word() => $this->faker()->word(), ]; $psrResponse->method('getHeaders')->willReturn($headers); - $responseBody = [$this->faker()->text]; + $responseBody = [$this->faker()->text()]; $responseBodyEncoded = json_encode($responseBody); $stream->expects(self::once())->method('getContents')->willReturn($responseBodyEncoded); $stream->expects(self::once())->method('rewind'); diff --git a/tests/Service/OAuth2AuthenticatorTest.php b/tests/Service/OAuth2AuthenticatorTest.php index 811a31e..6a5d21b 100644 --- a/tests/Service/OAuth2AuthenticatorTest.php +++ b/tests/Service/OAuth2AuthenticatorTest.php @@ -41,8 +41,8 @@ protected function setUp(): void public function test(): void { $endpointUri = $this->createMock(UriInterface::class); - $clientId = $this->faker()->uuid; - $clientSecret = $this->faker()->password; + $clientId = $this->faker()->uuid(); + $clientSecret = $this->faker()->password(); $payload = [ 'grant_type' => 'client_credentials', @@ -78,7 +78,7 @@ public function test(): void public function testInvalidPayload(): void { $endpointUri = $this->createMock(UriInterface::class); - $clientId = $this->faker()->uuid; + $clientId = $this->faker()->uuid(); $clientSecret = utf8_decode('äöä'); json_encode($clientSecret); @@ -89,8 +89,8 @@ public function testInvalidPayload(): void public function testHttpError(): void { $endpointUri = $this->createMock(UriInterface::class); - $clientId = $this->faker()->uuid; - $clientSecret = $this->faker()->password; + $clientId = $this->faker()->uuid(); + $clientSecret = $this->faker()->password(); $payload = [ 'grant_type' => 'client_credentials', diff --git a/tests/Validator/ResponseValidatorTest.php b/tests/Validator/ResponseValidatorTest.php index 7d12e99..b859f60 100644 --- a/tests/Validator/ResponseValidatorTest.php +++ b/tests/Validator/ResponseValidatorTest.php @@ -51,7 +51,7 @@ public function testAssertNoDocumentThrowsException(): void public function testAssertDataNotEmpty(): void { $this->responseValidator->assertDataNotEmpty($this->createResponse(new Document([new Resource( - $this->faker()->slug + $this->faker()->slug() )]))); $this->assertTrue(true); } @@ -66,7 +66,7 @@ public function testAssertDataNotEmptyThrowsException(): void public function testAssertResourcesMatchTypeAndContainIds(): void { - $type = $this->faker()->slug; + $type = $this->faker()->slug(); $response = $this->createResponse(new Document([new Resource( $type, (string) $this->faker()->numberBetween() @@ -77,8 +77,8 @@ public function testAssertResourcesMatchTypeAndContainIds(): void public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToType(): void { - $expectedType = $this->faker()->slug; - $actualType = $this->faker()->slug; + $expectedType = $this->faker()->slug(); + $actualType = $this->faker()->slug(); $response = $this->createResponse(new Document([new Resource( $actualType, (string) $this->faker()->numberBetween() @@ -91,7 +91,7 @@ public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToTyp public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToId(): void { - $expectedType = $this->faker()->slug; + $expectedType = $this->faker()->slug(); $response = $this->createResponse(new Document([new Resource( $expectedType )])); @@ -103,7 +103,7 @@ public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToId( public function testAssertScalarResultWithId(): void { - $type = $this->faker()->slug; + $type = $this->faker()->slug(); $response = $this->createResponse(new Document([new Resource( $type, (string) $this->faker()->numberBetween() @@ -114,7 +114,7 @@ public function testAssertScalarResultWithId(): void public function testAssertScalarResultWithIdThrowsException(): void { - $type = $this->faker()->slug; + $type = $this->faker()->slug(); $response = $this->createResponse(new Document([ new Resource($type, (string) $this->faker()->numberBetween()), new Resource($type, (string) $this->faker()->numberBetween()),