Skip to content

Commit 26a5b6a

Browse files
authored
Remove dms/phpunit-arraysubset-asserts (#2705)
1 parent f6b214f commit 26a5b6a

File tree

5 files changed

+66
-77
lines changed

5 files changed

+66
-77
lines changed

composer.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"require-dev": {
4646
"algolia/algoliasearch-client-php": "^3",
4747
"bensampo/laravel-enum": "^5 || ^6",
48-
"dms/phpunit-arraysubset-asserts": "^0.4 || ^0.5 || dev-add-phpunit-11-support",
4948
"ergebnis/composer-normalize": "^2.2.2",
5049
"fakerphp/faker": "^1.21",
5150
"google/protobuf": "^3.21",
@@ -80,12 +79,6 @@
8079
"mll-lab/laravel-graphiql": "A graphical interactive in-browser GraphQL IDE - integrated with Laravel",
8180
"pusher/pusher-php-server": "Required when using the Pusher Subscriptions driver"
8281
},
83-
"repositories": [
84-
{
85-
"type": "vcs",
86-
"url": "https://github.com/pieterocp/phpunit-arraysubset-asserts"
87-
}
88-
],
8982
"minimum-stability": "dev",
9083
"prefer-stable": true,
9184
"autoload": {
@@ -97,10 +90,7 @@
9790
"psr-4": {
9891
"Benchmarks\\": "benchmarks/",
9992
"Tests\\": "tests/"
100-
},
101-
"files": [
102-
"vendor/dms/phpunit-arraysubset-asserts/src/ArraySubsetAsserts.php"
103-
]
93+
}
10494
},
10595
"config": {
10696
"allow-plugins": {

tests/Integration/WhereConditions/WhereConditionsDirectiveTest.php

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Integration\WhereConditions;
44

55
use Carbon\Carbon;
6+
use GraphQL\Type\TypeKind;
67
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
78
use Nuwave\Lighthouse\WhereConditions\SQLOperator;
89
use Nuwave\Lighthouse\WhereConditions\WhereConditionsHandler;
@@ -941,24 +942,27 @@ public function testRequiresAValueForAColumn(): void
941942

942943
public function testOnlyAllowsWhitelistedColumns(): void
943944
{
944-
factory(User::class)->create();
945+
$user = factory(User::class)->create();
946+
assert($user instanceof User);
945947

946948
$this->graphQL(/** @lang GraphQL */ '
947-
{
949+
query ($id: Mixed!) {
948950
whitelistedColumns(
949951
where: {
950952
column: ID
951-
value: 1
953+
value: $id
952954
}
953955
) {
954956
id
955957
}
956958
}
957-
')->assertJson([
959+
', [
960+
'id' => $user->id,
961+
])->assertExactJson([
958962
'data' => [
959963
'whitelistedColumns' => [
960964
[
961-
'id' => 1,
965+
'id' => "{$user->id}",
962966
],
963967
],
964968
],
@@ -967,46 +971,42 @@ public function testOnlyAllowsWhitelistedColumns(): void
967971
$expectedEnumName = 'QueryWhitelistedColumnsWhereColumn';
968972
$enum = $this->introspectType($expectedEnumName);
969973

970-
$this->assertNotNull($enum);
974+
$this->assertIsArray($enum);
975+
$this->assertSame(TypeKind::ENUM, $enum['kind']);
976+
$this->assertSame($expectedEnumName, $enum['name']);
977+
$this->assertSame('Allowed column names for Query.whitelistedColumns.where.', $enum['description']);
971978

972-
$this->assertArraySubset(
973-
[
974-
'kind' => 'ENUM',
975-
'name' => $expectedEnumName,
976-
'description' => 'Allowed column names for Query.whitelistedColumns.where.',
977-
'enumValues' => [
978-
[
979-
'name' => 'ID',
980-
],
981-
[
982-
'name' => 'CAMEL_CASE',
983-
],
984-
],
985-
],
986-
$enum,
987-
);
979+
$enumValues = $enum['enumValues'];
980+
$this->assertCount(2, $enumValues);
981+
982+
[$idValue, $camelCaseValue] = $enumValues;
983+
$this->assertSame('ID', $idValue['name']);
984+
$this->assertSame('CAMEL_CASE', $camelCaseValue['name']);
988985
}
989986

990987
public function testUseColumnEnumsArg(): void
991988
{
992-
factory(User::class)->create();
989+
$user = factory(User::class)->create();
990+
assert($user instanceof User);
993991

994992
$this->graphQL(/** @lang GraphQL */ '
995-
{
993+
query ($id: Mixed!) {
996994
enumColumns(
997995
where: {
998996
column: ID
999-
value: 1
997+
value: $id
1000998
}
1001999
) {
10021000
id
10031001
}
10041002
}
1005-
')->assertJson([
1003+
', [
1004+
'id' => $user->id,
1005+
])->assertExactJson([
10061006
'data' => [
10071007
'enumColumns' => [
10081008
[
1009-
'id' => 1,
1009+
'id' => "{$user->id}",
10101010
],
10111011
],
10121012
],
@@ -1015,7 +1015,8 @@ enumColumns(
10151015

10161016
public function testIgnoreNullCondition(): void
10171017
{
1018-
factory(User::class)->create();
1018+
$user = factory(User::class)->create();
1019+
assert($user instanceof User);
10191020

10201021
$this->graphQL(/** @lang GraphQL */ '
10211022
{
@@ -1029,7 +1030,7 @@ public function testIgnoreNullCondition(): void
10291030
'data' => [
10301031
'users' => [
10311032
[
1032-
'id' => '1',
1033+
'id' => "{$user->id}",
10331034
],
10341035
],
10351036
],
@@ -1048,8 +1049,8 @@ public function testWhereConditionOnJSONColumn(): void
10481049
}
10491050
';
10501051

1051-
/** @var Location $location */
10521052
$location = factory(Location::class)->make();
1053+
assert($location instanceof Location);
10531054
$location->extra = [
10541055
'value' => 'exampleValue',
10551056
];
@@ -1089,18 +1090,18 @@ public function testHandler(): void
10891090
type Query {
10901091
users(where: _ @whereConditions(
10911092
columns: ["name"],
1092-
handler: "{$this->qualifyTestResolver('handler')}")
1093+
handler: "{$this->qualifyTestResolver('valueTwiceHandler')}")
10931094
): [User!]! @all
10941095
}
10951096
GRAPHQL;
10961097

1097-
/** @var User $user1 */
10981098
$user1 = factory(User::class)->make();
1099+
assert($user1 instanceof User);
10991100
$user1->name = 'foo';
11001101
$user1->save();
11011102

1102-
/** @var User $user2 */
11031103
$user2 = factory(User::class)->make();
1104+
assert($user2 instanceof User);
11041105
$user2->name = 'foofoo';
11051106
$user2->save();
11061107

@@ -1130,7 +1131,7 @@ public function testHandler(): void
11301131
* @param \Illuminate\Database\Eloquent\Builder<\Tests\Utils\Models\User> $builder
11311132
* @param array<string, mixed> $conditions
11321133
*/
1133-
public static function handler(EloquentBuilder $builder, array $conditions): void
1134+
public static function valueTwiceHandler(EloquentBuilder $builder, array $conditions): void
11341135
{
11351136
$value = $conditions['value'];
11361137
$builder->where($conditions['column'], $value . $value);

tests/TestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tests;
44

5-
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
65
use GraphQL\Error\DebugFlag;
76
use GraphQL\Type\Schema;
87
use Illuminate\Console\Application as ConsoleApplication;
@@ -34,7 +33,6 @@
3433

3534
abstract class TestCase extends TestbenchTestCase
3635
{
37-
use ArraySubsetAsserts;
3836
use MakesGraphQLRequests;
3937
use MocksResolvers;
4038
use UsesTestSchema;

tests/Unit/Schema/AST/DocumentASTTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tests\Unit\Schema\AST;
44

5-
use GraphQL\Language\AST\DirectiveDefinitionNode;
65
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
76
use GraphQL\Language\Parser;
87
use Nuwave\Lighthouse\Exceptions\DefinitionException;
@@ -107,7 +106,7 @@ public function testBeSerialized(): void
107106
$queryType = $reserialized->types[RootType::QUERY];
108107
$this->assertInstanceOf(ObjectTypeDefinitionNode::class, $queryType);
109108

110-
$this->assertInstanceOf(DirectiveDefinitionNode::class, $reserialized->directives['foo']);
109+
$this->assertArrayHasKey('foo', $reserialized->directives);
111110

112111
$this->assertSame(['Query'], $reserialized->classNameToObjectTypeNames[User::class]);
113112

tests/Unit/Schema/ClientDirectiveTest.php

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Tests\Unit\Schema;
44

5+
use GraphQL\Language\DirectiveLocation;
56
use GraphQL\Type\Definition\Directive;
7+
use GraphQL\Type\Definition\Type;
8+
use GraphQL\Type\TypeKind;
69
use Tests\TestCase;
710

811
final class ClientDirectiveTest extends TestCase
@@ -19,38 +22,36 @@ public function testReturnsDefaultDirectivesInIntrospection(): void
1922

2023
public function testDefineACustomClientDirective(): void
2124
{
22-
$this->schema .= /** @lang GraphQL */ '
25+
$this->schema .= /** @lang GraphQL */ <<<'GRAPHQL'
2326
"foo"
2427
directive @bar(
2528
"foobar"
2629
baz: String = "barbaz"
2730
) on FIELD
28-
';
29-
30-
$bar = $this->introspectDirective('bar');
31-
32-
$this->assertIsArray($bar);
33-
$this->assertArraySubset(
34-
[
35-
'name' => 'bar',
36-
'description' => 'foo',
37-
'args' => [
38-
[
39-
'name' => 'baz',
40-
'description' => 'foobar',
41-
'type' => [
42-
'kind' => 'SCALAR',
43-
'name' => 'String',
44-
'ofType' => null,
45-
],
46-
'defaultValue' => '"barbaz"',
47-
],
48-
],
49-
'locations' => [
50-
'FIELD',
51-
],
52-
],
53-
$bar,
54-
);
31+
GRAPHQL;
32+
33+
$introspection = $this->introspectDirective('bar');
34+
35+
$this->assertIsArray($introspection);
36+
$this->assertSame('bar', $introspection['name']);
37+
$this->assertSame('foo', $introspection['description']);
38+
39+
$args = $introspection['args'];
40+
$this->assertIsArray($args);
41+
$this->assertCount(1, $args);
42+
43+
[$argBaz] = $args;
44+
$this->assertIsArray($argBaz);
45+
$this->assertSame('baz', $argBaz['name']);
46+
$this->assertSame('foobar', $argBaz['description']);
47+
$this->assertSame('"barbaz"', $argBaz['defaultValue']);
48+
49+
$argBazType = $argBaz['type'];
50+
$this->assertIsArray($argBazType);
51+
$this->assertSame(TypeKind::SCALAR, $argBazType['kind']);
52+
$this->assertSame(Type::STRING, $argBazType['name']);
53+
$this->assertNull($argBazType['ofType']);
54+
55+
$this->assertSame([DirectiveLocation::FIELD], $introspection['locations']);
5556
}
5657
}

0 commit comments

Comments
 (0)