Skip to content

Commit bca949f

Browse files
committed
Extend ParserTest with query and new features
1 parent ece94ca commit bca949f

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Jerowork\GraphqlAttributeSchema\Test\Doubles\FullFeatured\Query;
6+
7+
use Jerowork\GraphqlAttributeSchema\Attribute\Arg;
8+
use Jerowork\GraphqlAttributeSchema\Attribute\Option\ListType;
9+
use Jerowork\GraphqlAttributeSchema\Attribute\Option\ScalarType;
10+
use Jerowork\GraphqlAttributeSchema\Attribute\Query;
11+
use DateTimeImmutable;
12+
13+
#[Query(name: 'getFoobar', type: new ListType(ScalarType::String))]
14+
final readonly class FoobarQuery
15+
{
16+
/**
17+
* @param list<bool> $values
18+
*
19+
* @return list<string>
20+
*/
21+
public function __invoke(
22+
int $id,
23+
DateTimeImmutable $date,
24+
#[Arg(type: new ListType(ScalarType::Bool))]
25+
array $values,
26+
): array {
27+
return [];
28+
}
29+
}

tests/Parser/ParserTest.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Jerowork\GraphqlAttributeSchema\Parser\NodeParser\TypeNodeParser;
2525
use Jerowork\GraphqlAttributeSchema\Parser\Parser;
2626
use Jerowork\GraphqlAttributeSchema\Test\Doubles\FullFeatured\Mutation\FoobarMutation;
27+
use Jerowork\GraphqlAttributeSchema\Test\Doubles\FullFeatured\Query\FoobarQuery;
2728
use Jerowork\GraphqlAttributeSchema\Test\Doubles\FullFeatured\Type\FoobarStatusType;
2829
use Jerowork\GraphqlAttributeSchema\Test\Doubles\FullFeatured\Type\FoobarType;
2930
use Jerowork\GraphqlAttributeSchema\Test\Doubles\FullFeatured\Type\Input\Baz;
@@ -83,7 +84,36 @@ public function it_should_parse_directory(): void
8384
),
8485
], $ast->getNodesByNodeType(MutationNode::class));
8586

86-
self::assertEquals([], $ast->getNodesByNodeType(QueryNode::class));
87+
self::assertEquals([
88+
new QueryNode(
89+
FoobarQuery::class,
90+
'getFoobar',
91+
null,
92+
[
93+
new ArgNode(
94+
Type::createScalar('int'),
95+
'id',
96+
null,
97+
'id',
98+
),
99+
new ArgNode(
100+
Type::createObject(DateTimeImmutable::class),
101+
'date',
102+
null,
103+
'date',
104+
),
105+
new ArgNode(
106+
Type::createScalar('bool')->setList(),
107+
'values',
108+
null,
109+
'values',
110+
),
111+
],
112+
Type::createScalar('string')->setList(),
113+
'__invoke',
114+
null,
115+
),
116+
], $ast->getNodesByNodeType(QueryNode::class));
87117

88118
self::assertEquals([
89119
new InputTypeNode(

tests/Util/Finder/Native/NativeFinderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function itShouldRetrieveFilesFromFolder(): void
3838

3939
self::assertSame([
4040
'Doubles/FullFeatured/Mutation/FoobarMutation.php',
41+
'Doubles/FullFeatured/Query/FoobarQuery.php',
4142
'Doubles/FullFeatured/Type/FoobarStatusType.php',
4243
'Doubles/FullFeatured/Type/FoobarType.php',
4344
'Doubles/FullFeatured/Type/Input/Baz.php',

0 commit comments

Comments
 (0)