Completed
Pull Request — master (#25)
by David
01:24
created

GlobTypeMapperTest::testGlobTypeMapperException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
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\Mappers;
4
5
use Doctrine\Common\Annotations\AnnotationReader;
6
use Mouf\Picotainer\Picotainer;
7
use Symfony\Component\Cache\Simple\NullCache;
8
use TheCodingMachine\GraphQL\Controllers\AbstractQueryProviderTest;
9
use TheCodingMachine\GraphQL\Controllers\Fixtures\TestObject;
10
use TheCodingMachine\GraphQL\Controllers\Fixtures\TestType;
11
use TheCodingMachine\GraphQL\Controllers\Fixtures\Types\FooType;
12
13
class GlobTypeMapperTest extends AbstractQueryProviderTest
14
{
15
    public function testGlobTypeMapper()
16
    {
17
        $container = new Picotainer([
18
            FooType::class => function() {
19
                return new FooType($this->getRegistry());
20
            }
21
        ]);
22
23
        $mapper = new GlobTypeMapper('TheCodingMachine\GraphQL\Controllers\Fixtures\Types', $container, new AnnotationReader(), new NullCache());
24
25
        $this->assertTrue($mapper->canMapClassToType(TestObject::class));
26
        $this->assertInstanceOf(FooType::class, $mapper->mapClassToType(TestObject::class));
27
    }
28
29
    public function testGlobTypeMapperException()
30
    {
31
        $container = new Picotainer([
32
            TestType::class => function() {
33
                return new TestType($this->getRegistry());
34
            }
35
        ]);
36
37
        $mapper = new GlobTypeMapper('TheCodingMachine\GraphQL\Controllers\Fixtures', $container, new AnnotationReader(), new NullCache());
38
39
        $this->expectException(DuplicateMappingException::class);
40
        $mapper->canMapClassToType(TestType::class);
41
    }
42
}
43