|
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
|
|
|
|