1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace GraphQLTests\Doctrine; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; |
8
|
|
|
use Doctrine\ORM\Mapping\Column; |
9
|
|
|
use Doctrine\ORM\Mapping\Entity; |
10
|
|
|
use GraphQL\Doctrine\Annotation\Field; |
11
|
|
|
use GraphQL\Doctrine\Factory\MetadataReader\MappingDriverChainAdapter; |
12
|
|
|
use GraphQLTests\Doctrine\Blog\Model\Post; |
13
|
|
|
|
14
|
|
|
class MappingDriverChainAdapterTest extends \PHPUnit\Framework\TestCase |
15
|
|
|
{ |
16
|
|
|
use TypesTrait { |
17
|
|
|
setUp as typeSetup; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
private $chainAdapter; |
21
|
|
|
|
22
|
|
|
public function setUp(): void |
23
|
|
|
{ |
24
|
|
|
$this->typeSetup(); |
25
|
|
|
|
26
|
|
|
$config = $this->entityManager->getConfiguration(); |
27
|
|
|
$chain = new MappingDriverChain(); |
28
|
|
|
$chain->setDefaultDriver($config->getMetadataDriverImpl()); |
29
|
|
|
$this->chainAdapter = new MappingDriverChainAdapter($chain); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGetClassAnnotations(): void |
33
|
|
|
{ |
34
|
|
|
self::assertNotEmpty($this->chainAdapter->getClassAnnotations(new \ReflectionClass(Post::class))); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testGetClassAnnotation(): void |
38
|
|
|
{ |
39
|
|
|
self::assertNotNull($this->chainAdapter->getClassAnnotation(new \ReflectionClass(Post::class), Entity::class)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testGetMethodAnnotations(): void |
43
|
|
|
{ |
44
|
|
|
self::assertNotEmpty($this->chainAdapter->getMethodAnnotations(new \ReflectionMethod(Post::class, 'getBody'))); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetMethodAnnotation(): void |
48
|
|
|
{ |
49
|
|
|
self::assertNotNull($this->chainAdapter->getMethodAnnotations(new \ReflectionMethod(Post::class, 'getBody'), Field::class)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testGetPropertyAnnotations(): void |
53
|
|
|
{ |
54
|
|
|
self::assertNotEmpty($this->chainAdapter->getPropertyAnnotations(new \ReflectionProperty(Post::class, 'body'))); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testGetPropertyAnnotation(): void |
58
|
|
|
{ |
59
|
|
|
self::assertNotNull($this->chainAdapter->getPropertyAnnotation(new \ReflectionProperty(Post::class, 'body'), Column::class)); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|