Skip to content

Commit

Permalink
Simplify BelongsToManyDirectiveTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Jan 18, 2023
1 parent 82000f7 commit edfe179
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions tests/Integration/Schema/Directives/BelongsToManyDirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function testQueryBelongsToManyRelationship(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$rolesCount = 2;
Expand Down Expand Up @@ -61,6 +62,7 @@ public function testNameRelationExplicitly(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$rolesCount = 2;
Expand Down Expand Up @@ -96,6 +98,7 @@ public function testQueryBelongsToManyPaginator(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$rolesCount = 4;
Expand Down Expand Up @@ -166,6 +169,7 @@ public function testQueryBelongsToManyRelayConnection(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$roles = factory(Role::class, 3)->create();
Expand Down Expand Up @@ -222,14 +226,12 @@ public function testQueryBelongsToManyRelayConnectionWithCustomEdgeUsingDirectiv
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$roles = factory(Role::class, 3)->create();
$meta = 'new';
$user->roles()->attach(
$roles,
['meta' => $meta]
);
$meta = ['meta' => 'new'];
$user->roles()->attach($roles, $meta);

$this->graphQL(/** @lang GraphQL */ '
{
Expand All @@ -249,9 +251,7 @@ public function testQueryBelongsToManyRelayConnectionWithCustomEdgeUsingDirectiv
'user' => [
'roles' => [
'edges' => [
[
'meta' => $meta,
],
$meta,
],
],
],
Expand Down Expand Up @@ -281,15 +281,13 @@ public function testQueryBelongsToManyPivot(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$rolesCount = 2;
$roles = factory(Role::class, $rolesCount)->create();
$meta = 'new';
$user->roles()->attach(
$roles,
['meta' => $meta]
);
$meta = ['meta' => 'new'];
$user->roles()->attach($roles, $meta);

$this->graphQL(/** @lang GraphQL */ '
{
Expand All @@ -307,9 +305,7 @@ public function testQueryBelongsToManyPivot(): void
'user' => [
'roles' => [
[
'pivot' => [
'meta' => $meta,
],
'pivot' => $meta,
],
],
],
Expand Down Expand Up @@ -356,14 +352,12 @@ public function testQueryBelongsToManyRelayConnectionWithCustomMagicEdge(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$roles = factory(Role::class, 3)->create();
$meta = 'new';
$user->roles()->attach(
$roles,
['meta' => $meta]
);
$meta = ['meta' => 'new'];
$user->roles()->attach($roles, $meta);

$this->graphQL(/** @lang GraphQL */ '
{
Expand All @@ -383,9 +377,7 @@ public function testQueryBelongsToManyRelayConnectionWithCustomMagicEdge(): void
'user' => [
'roles' => [
'edges' => [
[
'meta' => $meta,
],
$meta,
],
],
],
Expand Down Expand Up @@ -417,6 +409,7 @@ public function testQueryBelongsToManyNestedRelationships(): void
';

$user = factory(User::class)->create();
assert($user instanceof User);
$this->be($user);

$roles = factory(Role::class, 3)->create();
Expand Down

0 comments on commit edfe179

Please sign in to comment.