Completed
Pull Request — master (#78)
by David
02:26
created

TypeRegistryTest::testHasType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace TheCodingMachine\GraphQL\Controllers;
4
5
use GraphQL\Type\Definition\ObjectType;
6
use PHPUnit\Framework\TestCase;
7
8
class TypeRegistryTest extends TestCase
9
{
10
11
    public function testRegisterTypeException()
12
    {
13
        $type = new ObjectType([
14
            'name' => 'Foo',
15
            'fields' => function() {return [];}
16
        ]);
17
18
        $registry = new TypeRegistry();
19
        $registry->registerType($type);
20
21
        $this->expectException(GraphQLException::class);
22
        $registry->registerType($type);
23
    }
24
25
    public function testGetType()
26
    {
27
        $type = new ObjectType([
28
            'name' => 'Foo',
29
            'fields' => function() {return [];}
30
        ]);
31
32
        $registry = new TypeRegistry();
33
        $registry->registerType($type);
34
35
        $this->assertSame($type, $registry->getType('Foo'));
36
37
        $this->expectException(GraphQLException::class);
38
        $registry->getType('Bar');
39
    }
40
41
    public function testHasType()
42
    {
43
        $type = new ObjectType([
44
            'name' => 'Foo',
45
            'fields' => function() {return [];}
46
        ]);
47
48
        $registry = new TypeRegistry();
49
        $registry->registerType($type);
50
51
        $this->assertTrue($registry->hasType('Foo'));
52
        $this->assertFalse($registry->hasType('Bar'));
53
54
    }
55
}
56