1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace GraphQLTests\Doctrine; |
6
|
|
|
|
7
|
|
|
use GraphQLTests\Doctrine\Blog\Model\Post; |
8
|
|
|
use GraphQLTests\Doctrine\Blog\Model\User; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
final class InputTypesTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
use TypesTrait; |
14
|
|
|
|
15
|
|
|
public function testCanGetInputTypes(): void |
16
|
|
|
{ |
17
|
|
|
$userType = $this->types->getInput(User::class); |
18
|
|
|
$this->assertType('tests/data/UserInput.graphqls', $userType); |
19
|
|
|
self::assertSame($userType, $this->types->getInput(User::class), 'must returns the same instance of user type'); |
20
|
|
|
|
21
|
|
|
$postType = $this->types->getInput(Post::class); |
22
|
|
|
$this->assertType('tests/data/PostInput.graphqls', $postType); |
23
|
|
|
self::assertSame($postType, $this->types->getInput(Post::class), 'must returns the same instance of post type'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testDefaultValuesInput(): void |
27
|
|
|
{ |
28
|
|
|
$actual = $this->types->getInput(Blog\Model\Special\DefaultValue::class); |
29
|
|
|
$this->assertType('tests/data/DefaultValueInput.graphqls', $actual); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testDefaultValuesPartialInput(): void |
33
|
|
|
{ |
34
|
|
|
$actual = $this->types->getPartialInput(Blog\Model\Special\DefaultValue::class); |
35
|
|
|
$this->assertType('tests/data/DefaultValuePartialInput.graphqls', $actual); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testSelfSupportInput(): void |
39
|
|
|
{ |
40
|
|
|
$actual = $this->types->getInput(Blog\Model\Special\SelfSupport::class); |
41
|
|
|
$this->assertType('tests/data/SelfSupportInput.graphqls', $actual); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testNamespaceSupportInput(): void |
45
|
|
|
{ |
46
|
|
|
$actual = $this->types->getInput(Blog\Model\Special\NamespaceSupport::class); |
47
|
|
|
$this->assertType('tests/data/NamespaceSupportInput.graphqls', $actual); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testInputWithId(): void |
51
|
|
|
{ |
52
|
|
|
$actual = $this->types->getInput(Blog\Model\Special\InputWithId::class); |
53
|
|
|
$this->assertType('tests/data/InputWithId.graphqls', $actual); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testInputWithoutTypeMustThrow(): void |
57
|
|
|
{ |
58
|
|
|
$type = $this->types->getInput(Blog\Model\Special\NoTypeInput::class); |
59
|
|
|
|
60
|
|
|
$this->expectExceptionMessage('Could not find type for parameter `$bar` for method `GraphQLTests\Doctrine\Blog\Model\Special\NoTypeInput::setFoo()`. Either type hint the parameter, or specify the type with `#[API\Input]` attribute.'); |
61
|
|
|
$type->getFields(); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|