Failed Conditions
Pull Request — master (#10)
by Adrien
02:25
created

InputTypesTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 32
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testDefaultValuesPartialInput() 0 4 1
A testDefaultValuesInput() 0 4 1
A testInputWithoutTypeMustThrow() 0 5 1
A testCanGetInputTypes() 0 9 1
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
10
class InputTypesTest extends \PHPUnit\Framework\TestCase
11
{
12
    use TypesTrait;
13
14
    public function testCanGetInputTypes(): void
15
    {
16
        $userType = $this->types->getInput(User::class);
17
        $this->assertType('tests/data/UserInput.graphqls', $userType);
18
        self::assertSame($userType, $this->types->getInput(User::class), 'must returns the same instance of user type');
19
20
        $postType = $this->types->getInput(Post::class);
21
        $this->assertType('tests/data/PostInput.graphqls', $postType);
22
        self::assertSame($postType, $this->types->getInput(Post::class), 'must returns the same instance of post type');
23
    }
24
25
    public function testDefaultValuesInput(): void
26
    {
27
        $actual = $this->types->getInput(Blog\Model\Special\DefaultValue::class);
28
        $this->assertType('tests/data/DefaultValueInput.graphqls', $actual);
29
    }
30
31
    public function testDefaultValuesPartialInput(): void
32
    {
33
        $actual = $this->types->getPartialInput(Blog\Model\Special\DefaultValue::class);
34
        $this->assertType('tests/data/DefaultValuePartialInput.graphqls', $actual);
35
    }
36
37
    public function testInputWithoutTypeMustThrow(): void
38
    {
39
        $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` annotation.');
40
        $type = $this->types->getInput(Blog\Model\Special\NoTypeInput::class);
41
        $type->getFields();
42
    }
43
}
44