Passed
Pull Request — master (#64)
by David
01:38
created

InputTypeUtilsTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 43
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A factoryNullableReturnType() 0 3 1
A factoryNoReturnType() 0 2 1
A testNoReturnType() 0 7 1
A testInvalidReturnType() 0 7 1
A factoryStringReturnType() 0 3 1
A testNullableReturnType() 0 7 1
1
<?php
2
3
namespace TheCodingMachine\GraphQL\Controllers;
4
5
use ReflectionMethod;
6
use TheCodingMachine\GraphQL\Controllers\Fixtures\TestObject;
7
8
class InputTypeUtilsTest extends AbstractQueryProviderTest
9
{
10
11
    public function testNoReturnType()
12
    {
13
        $inputTypeGenerator = $this->getInputTypeUtils();
14
15
        $this->expectException(MissingTypeHintException::class);
16
        $this->expectExceptionMessage('Factory "TheCodingMachine\\GraphQL\\Controllers\\InputTypeUtilsTest::factoryNoReturnType" must have a return type.');
17
        $inputTypeGenerator->getInputTypeNameAndClassName(new ReflectionMethod($this, 'factoryNoReturnType'));
18
    }
19
20
    public function testInvalidReturnType()
21
    {
22
        $inputTypeGenerator = $this->getInputTypeUtils();
23
24
        $this->expectException(MissingTypeHintException::class);
25
        $this->expectExceptionMessage('The return type of factory "TheCodingMachine\\GraphQL\\Controllers\\InputTypeUtilsTest::factoryStringReturnType" must be an object, "string" passed instead.');
26
        $inputTypeGenerator->getInputTypeNameAndClassName(new ReflectionMethod($this, 'factoryStringReturnType'));
27
    }
28
29
    public function testNullableReturnType()
30
    {
31
        $inputTypeGenerator = $this->getInputTypeUtils();
32
33
        $this->expectException(MissingTypeHintException::class);
34
        $this->expectExceptionMessage('Factory "TheCodingMachine\\GraphQL\\Controllers\\InputTypeUtilsTest::factoryNullableReturnType" must have a non nullable return type.');
35
        $inputTypeGenerator->getInputTypeNameAndClassName(new ReflectionMethod($this, 'factoryNullableReturnType'));
36
    }
37
38
    public function factoryNoReturnType()
39
    {
40
        
41
    }
42
43
    public function factoryStringReturnType(): string
44
    {
45
        return '';
46
    }
47
48
    public function factoryNullableReturnType(): ?TestObject
49
    {
50
        return null;
51
    }
52
53
}
54