Skip to content

Commit c419a39

Browse files
chore: resolve faker deprecations (#6)
1 parent 3949c42 commit c419a39

File tree

5 files changed

+62
-62
lines changed

5 files changed

+62
-62
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "^9.5",
21-
"fakerphp/faker": "^1.10",
21+
"fakerphp/faker": "^1.15",
2222
"phpstan/phpstan": "^0.12.49",
2323
"guzzlehttp/psr7": "^1.7",
2424
"squizlabs/php_codesniffer": "^3.5"

tests/Decorator/ResponseDecoratorTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ public function testNoDocument(): void
2727
*/
2828
public function testIncludeRelationship(): void
2929
{
30-
$relatedResource = new Resource($this->faker()->slug, (string) $this->faker()->numberBetween(), [
31-
'name' => $this->faker()->domainName,
30+
$relatedResource = new Resource($this->faker()->slug(), (string) $this->faker()->numberBetween(), [
31+
'name' => $this->faker()->domainName(),
3232
]);
33-
$relationship = new Relationship($this->faker->slug, $relatedResource);
33+
$relationship = new Relationship($this->faker->slug(), $relatedResource);
3434

35-
$resource = new Resource($this->faker()->slug, (string) $this->faker->numberBetween());
35+
$resource = new Resource($this->faker()->slug(), (string) $this->faker->numberBetween());
3636
$resource->relationships()->set($relationship);
3737
$document = new Document($resource);
3838

3939
$uri = sprintf(
4040
'http://%s/%s/%s/relationships/%s?include=%s',
41-
$this->faker()->domainName,
41+
$this->faker()->domainName(),
4242
$resource->type(),
4343
$resource->id(),
4444
$relationship->name(),
@@ -60,16 +60,16 @@ public function testIncludeRelationship(): void
6060
*/
6161
public function testCleanupAttributes(): void
6262
{
63-
$resource = new Resource($this->faker()->slug, (string) $this->faker->numberBetween(), [
64-
'name' => $this->faker()->domainName,
63+
$resource = new Resource($this->faker()->slug(), (string) $this->faker->numberBetween(), [
64+
'name' => $this->faker()->domainName(),
6565
]);
66-
$relationship = new Relationship($this->faker->slug);
66+
$relationship = new Relationship($this->faker->slug());
6767
$resource->relationships()->set($relationship);
6868
$document = new Document($resource);
6969

7070
$uri = sprintf(
7171
'http://%s/%s/%s?fields[%s]=test&include=foobar',
72-
$this->faker()->domainName,
72+
$this->faker()->domainName(),
7373
$resource->type(),
7474
$resource->id(),
7575
$resource->type()
@@ -87,19 +87,19 @@ public function testCleanupAttributes(): void
8787
*/
8888
public function testCleanupRelationships(): void
8989
{
90-
$relatedResource = new Resource($this->faker()->slug, (string) $this->faker()->numberBetween(), [
91-
'name' => $this->faker()->domainName,
90+
$relatedResource = new Resource($this->faker()->slug(), (string) $this->faker()->numberBetween(), [
91+
'name' => $this->faker()->domainName(),
9292
]);
93-
$relatedResource->relationships()->set(new Relationship($this->faker->slug));
94-
$relationship = new Relationship($this->faker->slug, $relatedResource);
93+
$relatedResource->relationships()->set(new Relationship($this->faker->slug()));
94+
$relationship = new Relationship($this->faker->slug(), $relatedResource);
9595

96-
$resource = new Resource($this->faker()->slug, (string) $this->faker->numberBetween());
96+
$resource = new Resource($this->faker()->slug(), (string) $this->faker->numberBetween());
9797
$resource->relationships()->set($relationship);
9898
$document = new Document($resource);
9999

100100
$uri = sprintf(
101101
'http://%s/%s/%s/relationships/%s',
102-
$this->faker()->domainName,
102+
$this->faker()->domainName(),
103103
$resource->type(),
104104
$resource->id(),
105105
$relationship->name()

tests/JsonApiServerTest.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,84 +68,84 @@ public function testHandlerAssociations(string $method, string $type, string $ur
6868

6969
public function handlerAssociationScenarios(): Generator
7070
{
71-
$type = $this->faker()->slug;
71+
$type = $this->faker()->slug();
7272
$uri = sprintf(
7373
'http://%s/%s/%s/relationships/%s',
74-
$this->faker()->domainName,
74+
$this->faker()->domainName(),
7575
$type,
7676
$this->faker()->numberBetween(),
77-
$this->faker()->slug
77+
$this->faker()->slug()
7878
);
7979
yield ['GET', $type, $uri, 'fetchRelationship'];
8080

81-
$type = $this->faker()->slug;
81+
$type = $this->faker()->slug();
8282
$uri = sprintf(
8383
'http://%s/%s/%s',
84-
$this->faker()->domainName,
84+
$this->faker()->domainName(),
8585
$type,
8686
$this->faker()->numberBetween()
8787
);
8888
yield ['GET', $type, $uri, 'fetchResource'];
8989

90-
$type = $this->faker()->slug;
90+
$type = $this->faker()->slug();
9191
$uri = sprintf(
9292
'http://%s/%s',
93-
$this->faker()->domainName,
93+
$this->faker()->domainName(),
9494
$type
9595
);
9696
yield ['GET', $type, $uri, 'fetchResources'];
9797

98-
$type = $this->faker()->slug;
98+
$type = $this->faker()->slug();
9999
$uri = sprintf(
100100
'http://%s/%s/%s/relationships/%s',
101-
$this->faker()->domainName,
101+
$this->faker()->domainName(),
102102
$type,
103103
$this->faker()->numberBetween(),
104-
$this->faker()->slug
104+
$this->faker()->slug()
105105
);
106106
yield ['POST', $type, $uri, 'addRelatedResources'];
107107

108-
$type = $this->faker()->slug;
108+
$type = $this->faker()->slug();
109109
$uri = sprintf(
110110
'http://%s/%s',
111-
$this->faker()->domainName,
111+
$this->faker()->domainName(),
112112
$type
113113
);
114114
yield ['POST', $type, $uri, 'createResource'];
115115

116-
$type = $this->faker()->slug;
116+
$type = $this->faker()->slug();
117117
$uri = sprintf(
118118
'http://%s/%s/%s/relationships/%s',
119-
$this->faker()->domainName,
119+
$this->faker()->domainName(),
120120
$type,
121121
$this->faker()->numberBetween(),
122-
$this->faker()->slug
122+
$this->faker()->slug()
123123
);
124124
yield ['PATCH', $type, $uri, 'replaceRelatedResources'];
125125

126-
$type = $this->faker()->slug;
126+
$type = $this->faker()->slug();
127127
$uri = sprintf(
128128
'http://%s/%s/%s',
129-
$this->faker()->domainName,
129+
$this->faker()->domainName(),
130130
$type,
131131
$this->faker()->numberBetween()
132132
);
133133
yield ['PATCH', $type, $uri, 'patchResource'];
134134

135-
$type = $this->faker()->slug;
135+
$type = $this->faker()->slug();
136136
$uri = sprintf(
137137
'http://%s/%s/%s/relationships/%s',
138-
$this->faker()->domainName,
138+
$this->faker()->domainName(),
139139
$type,
140140
$this->faker()->numberBetween(),
141-
$this->faker()->slug
141+
$this->faker()->slug()
142142
);
143143
yield ['DELETE', $type, $uri, 'removeRelatedResources'];
144144

145-
$type = $this->faker()->slug;
145+
$type = $this->faker()->slug();
146146
$uri = sprintf(
147147
'http://%s/%s/%s',
148-
$this->faker()->domainName,
148+
$this->faker()->domainName(),
149149
$type,
150150
$this->faker()->numberBetween()
151151
);
@@ -154,10 +154,10 @@ public function handlerAssociationScenarios(): Generator
154154

155155
public function testUnknownType(): void
156156
{
157-
$type = $this->faker()->slug;
157+
$type = $this->faker()->slug();
158158
$uri = sprintf(
159159
'http://%s/%s/%s',
160-
$this->faker()->domainName,
160+
$this->faker()->domainName(),
161161
$type,
162162
$this->faker()->numberBetween()
163163
);
@@ -168,25 +168,25 @@ public function testUnknownType(): void
168168

169169
public function testInvalidContentType(): void
170170
{
171-
$type = $this->faker()->slug;
171+
$type = $this->faker()->slug();
172172
$uri = sprintf(
173173
'http://%s/%s/%s',
174-
$this->faker()->domainName,
174+
$this->faker()->domainName(),
175175
$type,
176176
$this->faker()->numberBetween()
177177
);
178178
$request = new Request('GET', new Uri($uri));
179-
$request->headers()->set('Content-Type', $this->faker()->slug);
179+
$request->headers()->set('Content-Type', $this->faker()->slug());
180180
$this->expectExceptionObject(new UnsupportedMediaTypeException($request->headers()->get('Content-Type')));
181181
$this->server->handleRequest($request);
182182
}
183183

184184
public function testInvalidHttpMethod(): void
185185
{
186-
$type = $this->faker()->slug;
186+
$type = $this->faker()->slug();
187187
$this->server->addHandler($type, $this->requestHandler);
188188

189-
$method = $this->faker()->userName;
189+
$method = $this->faker()->userName();
190190
$request = $this->createMock(Request::class);
191191

192192
$headers = new KeyValueCollection(['Content-Type' => JsonApiInterface::CONTENT_TYPE]);
@@ -206,12 +206,12 @@ public function testCreateRequestBodyEmpty(): void
206206
public function testCreateRequestBodyInvalidJson(): void
207207
{
208208
$this->expectException(BadRequestException::class);
209-
$this->server->createRequestBody($this->faker()->text);
209+
$this->server->createRequestBody($this->faker()->text());
210210
}
211211

212212
public function testCreateRequestBody(): void
213213
{
214-
$data = [$this->faker()->text];
214+
$data = [$this->faker()->text()];
215215
$jsonData = json_encode($data);
216216
$document = $this->createMock(DocumentInterface::class);
217217
$this->deserializer->expects(self::once())->method('deserializeDocument')->with($data)->willReturn($document);
@@ -241,7 +241,7 @@ public function testCreateResponseBodyInvalidJson(): void
241241
public function testCreateResponseBody(): void
242242
{
243243
$response = $this->createMock(ResponseInterface::class);
244-
$data = [$this->faker()->text];
244+
$data = [$this->faker()->text()];
245245

246246
$document = $this->createMock(DocumentInterface::class);
247247
$response->method('document')->willReturn($document);
@@ -253,7 +253,7 @@ public function testCreateResponseBody(): void
253253
public function testHandleException(): void
254254
{
255255
$throwable = $this->createMock(Throwable::class);
256-
$debug = $this->faker()->boolean;
256+
$debug = $this->faker()->boolean();
257257
$apiError = Error::createFrom($throwable, $debug);
258258

259259
$document = new Document();

tests/Validator/ModelValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testValidateWithCustomDocumentPath(): void
3737
$validatorBuilder = new ValidatorBuilder();
3838
$validator = $validatorBuilder->enableAnnotationMapping()->getValidator();
3939

40-
$customPath = '/' . $this->faker()->word . '/' . $this->faker()->word;
40+
$customPath = '/' . $this->faker()->word() . '/' . $this->faker()->word();
4141
$jsonApiValidator = new ModelValidator($validator);
4242
try {
4343
$jsonApiValidator->validate($model, null, null, $customPath);

tests/Validator/RequestValidatorTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testAssertNoDocumentThrowsException(): void
5353
public function testAssertDataNotEmpty(): void
5454
{
5555
$this->requestValidator->assertDataNotEmpty($this->createRequest(new Document([new Resource(
56-
$this->faker()->slug
56+
$this->faker()->slug()
5757
)])));
5858
$this->assertTrue(true);
5959
}
@@ -68,7 +68,7 @@ public function testAssertDataNotEmptyThrowsException(): void
6868

6969
public function testAssertResourcesMatchType(): void
7070
{
71-
$type = $this->faker()->slug;
71+
$type = $this->faker()->slug();
7272
$request = $this->createRequest(new Document([new Resource(
7373
$type
7474
)]));
@@ -78,9 +78,9 @@ public function testAssertResourcesMatchType(): void
7878

7979
public function testAssertResourcesMatchTypeThrowsException(): void
8080
{
81-
$type = $this->faker()->slug;
81+
$type = $this->faker()->slug();
8282
$resource = new Resource(
83-
$this->faker()->slug
83+
$this->faker()->slug()
8484
);
8585
$request = $this->createRequest(new Document([$resource]));
8686
$this->expectExceptionObject(RequestValidationException::typeMismatch($request, $type, $resource->type(), 0));
@@ -89,7 +89,7 @@ public function testAssertResourcesMatchTypeThrowsException(): void
8989

9090
public function testAssertResourcesMatchTypeAndContainIds(): void
9191
{
92-
$type = $this->faker()->slug;
92+
$type = $this->faker()->slug();
9393
$request = $this->createRequest(new Document([new Resource(
9494
$type,
9595
(string) $this->faker()->numberBetween()
@@ -100,8 +100,8 @@ public function testAssertResourcesMatchTypeAndContainIds(): void
100100

101101
public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToType(): void
102102
{
103-
$expectedType = $this->faker()->slug;
104-
$actualType = $this->faker()->slug;
103+
$expectedType = $this->faker()->slug();
104+
$actualType = $this->faker()->slug();
105105
$request = $this->createRequest(new Document([new Resource(
106106
$actualType,
107107
(string) $this->faker()->numberBetween()
@@ -114,7 +114,7 @@ public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToTyp
114114

115115
public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToId(): void
116116
{
117-
$expectedType = $this->faker()->slug;
117+
$expectedType = $this->faker()->slug();
118118
$request = $this->createRequest(new Document([new Resource(
119119
$expectedType
120120
)]));
@@ -126,7 +126,7 @@ public function testAssertResourcesMatchTypeAndContainIdsThrowsExceptionDueToId(
126126

127127
public function testAssertScalarResultWithId(): void
128128
{
129-
$type = $this->faker()->slug;
129+
$type = $this->faker()->slug();
130130
$request = $this->createRequest(new Document([new Resource(
131131
$type,
132132
(string) $this->faker()->numberBetween()
@@ -137,7 +137,7 @@ public function testAssertScalarResultWithId(): void
137137

138138
public function testAssertScalarResultWithIdThrowsException(): void
139139
{
140-
$type = $this->faker()->slug;
140+
$type = $this->faker()->slug();
141141
$request = $this->createRequest(new Document([
142142
new Resource($type, (string) $this->faker()->numberBetween()),
143143
new Resource($type, (string) $this->faker()->numberBetween()),
@@ -151,7 +151,7 @@ public function testAssertScalarResultWithIdThrowsException(): void
151151

152152
public function testAssertScalarResultWithoutId(): void
153153
{
154-
$type = $this->faker()->slug;
154+
$type = $this->faker()->slug();
155155
$request = $this->createRequest(new Document([new Resource(
156156
$type
157157
)]));
@@ -161,7 +161,7 @@ public function testAssertScalarResultWithoutId(): void
161161

162162
public function testAssertScalarResultWithoutIdThrowsException(): void
163163
{
164-
$type = $this->faker()->slug;
164+
$type = $this->faker()->slug();
165165
$request = $this->createRequest(new Document([
166166
new Resource($type, (string) $this->faker()->numberBetween()),
167167
]));

0 commit comments

Comments
 (0)