-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInputObjectBuilderTest.php
More file actions
51 lines (43 loc) · 1.65 KB
/
InputObjectBuilderTest.php
File metadata and controls
51 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
namespace SimPod\GraphQLUtils\Tests\Builder;
use GraphQL\Type\Definition\InputObjectField;
use GraphQL\Type\Definition\InterfaceType;
use GraphQL\Type\Definition\Type;
use PHPUnit\Framework\TestCase;
use SimPod\GraphQLUtils\Builder\InputFieldBuilder;
use SimPod\GraphQLUtils\Builder\InputObjectBuilder;
use SimPod\GraphQLUtils\Builder\InterfaceBuilder;
final class InputObjectBuilderTest extends TestCase
{
public function testCreate(): void
{
$description = 'To the sichuan-style nachos add ghee, noodles, buttermilk and heated herring.';
$name = 'SomeType';
$interface = new class () extends InterfaceType {
public function __construct()
{
$builder = InterfaceBuilder::create('InterfaceA');
parent::__construct($builder->build());
}
};
$fieldResolver = static function (): void {
};
$builder = InputObjectBuilder::create($name);
$object = $builder
->setDescription($description)
->setFields(
[
InputFieldBuilder::create('SomeField', Type::string())->build(),
new InputObjectField(InputFieldBuilder::create('Another', Type::string())->build()),
],
)
->build();
self::assertArrayHasKey('name', $object);
self::assertSame($name, $object['name']);
self::assertArrayHasKey('description', $object);
self::assertSame($description, $object['description']);
self::assertIsArray($object['fields']);
self::assertCount(2, $object['fields']);
}
}