Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions tests/Action/ActionTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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]);
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/ResponseValidationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
12 changes: 6 additions & 6 deletions tests/Factory/Oauth2/CredentialFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down
16 changes: 8 additions & 8 deletions tests/Factory/RequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -26,8 +26,8 @@ public function providesRequestData(): array
* [<expected values>]
* ]
*/
$type = $this->faker()->word;
$relationshipType = $this->faker()->word;
$type = $this->faker()->word();
$relationshipType = $this->faker()->word();
$id = $this->faker()->randomNumber(5);
return [
[ #0
Expand Down Expand Up @@ -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());
Expand Down
14 changes: 7 additions & 7 deletions tests/JsonApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down
10 changes: 5 additions & 5 deletions tests/Middleware/AuthenticationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/Model/Auth2CredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Model/BasicCredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tests/Response/ResponseFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ 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');

$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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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');
Expand Down
10 changes: 5 additions & 5 deletions tests/Service/OAuth2AuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand All @@ -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',
Expand Down
14 changes: 7 additions & 7 deletions tests/Validator/ResponseValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
)]));
Expand All @@ -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()
Expand All @@ -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()),
Expand Down