Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Oct 11, 2023
1 parent 3a88e6c commit 82c46c9
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 32 deletions.
11 changes: 6 additions & 5 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
->setRules([
'@PSR12' => true,
'@PSR12:risky' => true,
'no_unused_imports' => true,
'array_indentation' => true,
'declare_strict_types' => true,
'explicit_string_variable' => true,
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'native_function_invocation' => true,
'declare_strict_types' => true,
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'single_quote' => true,
'strict_comparison' => true,
'strict_param' => true,
'explicit_string_variable' => true,
'trailing_comma_in_multiline' => true,
'array_indentation' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
])
->setRiskyAllowed(true)
->setFinder($finder);
32 changes: 16 additions & 16 deletions tests/Feature/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@ public function testItCanPaginate(): void
'last_page' => 3,
'total' => 5,
'path' => 'http://localhost/test-route',
"links" => [
'links' => [
[
"active" => false,
"label" => "« Previous",
"url" => null,
'active' => false,
'label' => '« Previous',
'url' => null,
],
[
"active" => true,
"label" => "1",
"url" => "http://localhost/test-route?page=1",
'active' => true,
'label' => '1',
'url' => 'http://localhost/test-route?page=1',
],
[
"active" => false,
"label" => "2",
"url" => "http://localhost/test-route?page=2",
'active' => false,
'label' => '2',
'url' => 'http://localhost/test-route?page=2',
],
[
"active" => false,
"label" => "3",
"url" => "http://localhost/test-route?page=3",
'active' => false,
'label' => '3',
'url' => 'http://localhost/test-route?page=3',
],
[
"active" => false,
"label" => "Next »",
"url" => "http://localhost/test-route?page=2",
'active' => false,
'label' => 'Next »',
'url' => 'http://localhost/test-route?page=2',
],
],
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/JsonApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function testItCanCustomiseTheTypeResolution(): void
JsonApiResource::resolveTypeUsing(fn (BasicModel $model): string => $model::class);
Route::get('test-route', fn () => BasicJsonApiResource::make((new BasicModel(['id' => 'expected-id']))));

$response = $this->get("test-route");
$response = $this->get('test-route');

$response->assertExactJson([
'data' => [
Expand All @@ -217,7 +217,7 @@ public function testItCanCustomiseTheIdResolution(): void
JsonApiResource::resolveIdUsing(fn (BasicModel $model): string => 'expected-id');
Route::get('test-route', fn () => BasicJsonApiResource::make((new BasicModel(['id' => 'missing-id']))));

$response = $this->get("test-route");
$response = $this->get('test-route');

$response->assertExactJson([
'data' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/RelationshipsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ public function testItCanReturnAnEmptyArrayForEmptyToManyRelationships(): void
],
'relationships' => [
'posts' => [
"data" => [],
'data' => [],
],
],
],
Expand All @@ -1066,7 +1066,7 @@ public function testItFlushesTheRelationshipCache(): void
$resource = UserResource::make($user);
Route::get('test-route', fn () => $resource);

$response = $this->get("test-route?include=posts");
$response = $this->get('test-route?include=posts');

$response->assertOk();
$this->assertValidJsonApi($response);
Expand Down
2 changes: 1 addition & 1 deletion tests/Performance/FieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
}
$end = microtime(true);

echo "Duration (milliseconds):".PHP_EOL;
echo 'Duration (milliseconds):'.PHP_EOL;
echo($end - $start) * 1000;
2 changes: 1 addition & 1 deletion tests/Performance/IncludesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
}
$end = microtime(true);

echo "Duration (milliseconds):".PHP_EOL;
echo 'Duration (milliseconds):'.PHP_EOL;
echo($end - $start) * 1000;
4 changes: 2 additions & 2 deletions tests/Performance/RequestRelationshipsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public function header(): void
$modelFactory()->setRelation('author', $modelFactory())->setRelation('avatar', $modelFactory()),
]);
}
$request = Request::create("https://example.com/users?include=posts.author.avatar,comments.author.avatar", 'GET');
$request = Request::create('https://example.com/users?include=posts.author.avatar,comments.author.avatar', 'GET');
Container::getInstance()->bind('request', fn () => $request);
$resource = UserResource::collection($users);

$start = microtime(true);
$resource->toResponse($request);
$end = microtime(true);

echo "Duration (milliseconds):".PHP_EOL;
echo 'Duration (milliseconds):'.PHP_EOL;
echo($end - $start) * 1000;
2 changes: 1 addition & 1 deletion tests/Unit/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testMetaCanBeAppended(): void
$link = Link::related('https://related.com', ['original' => 'meta']);

$serialized = json_encode(
$link->withMeta(['expected' => 'meta'])->withMeta(["another" => "one"])
$link->withMeta(['expected' => 'meta'])->withMeta(['another' => 'one'])
);

$this->assertSame('{"href":"https:\/\/related.com","meta":{"original":"meta","expected":"meta","another":"one"}}', $serialized);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/RelationshipObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testMissingMetaAndLinksIsExcluded(): void

public function testMetaAndLinksCanBeAppended(): void
{
$link = RelationshipObject::toMany([new ResourceIdentifier('expected-type', 'expected-id')], [Link::related('related.com')], ["original" => "meta"]);
$link = RelationshipObject::toMany([new ResourceIdentifier('expected-type', 'expected-id')], [Link::related('related.com')], ['original' => 'meta']);

$serialized = json_encode(
$link->withMeta(['expected' => 'meta'])->withMeta(['another' => 'one'])
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ResourceIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testMetaCanBeAppended(): void
$identifier = (new ResourceIdentifier('expected-type', 'expected-id', ['original' => 'meta']));

$serialized = json_encode(
$identifier->withMeta(['expected' => 'meta'])->withMeta(["another" => "one"])
$identifier->withMeta(['expected' => 'meta'])->withMeta(['another' => 'one'])
);

$this->assertSame('{"type":"expected-type","id":"expected-id","meta":{"original":"meta","expected":"meta","another":"one"}}', $serialized);
Expand Down

0 comments on commit 82c46c9

Please sign in to comment.