1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\Persistence\Mapping; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
8
|
|
|
use Doctrine\Entity; |
9
|
|
|
use Doctrine\Persistence\Mapping\ClassMetadata; |
10
|
|
|
use Doctrine\Persistence\Mapping\Driver\AnnotationDriver; |
11
|
|
|
use Doctrine\TestClass; |
12
|
|
|
use Doctrine\Tests\Persistence\TestObject; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
class AnnotationDriverTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
/** @var AnnotationReader */ |
18
|
|
|
private $reader; |
19
|
|
|
|
20
|
|
|
/** @var SimpleAnnotationDriver */ |
21
|
|
|
private $driver; |
22
|
|
|
|
23
|
|
|
public function testAddGetPaths() : void |
24
|
|
|
{ |
25
|
|
|
self::assertSame([ |
26
|
|
|
__DIR__ . '/_files/annotation', |
27
|
|
|
], $this->driver->getPaths()); |
28
|
|
|
|
29
|
|
|
$this->driver->addPaths(['/test/path1', '/test/path2']); |
30
|
|
|
|
31
|
|
|
self::assertSame([ |
32
|
|
|
__DIR__ . '/_files/annotation', |
33
|
|
|
'/test/path1', |
34
|
|
|
'/test/path2', |
35
|
|
|
], $this->driver->getPaths()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testAddGetExcludePaths() : void |
39
|
|
|
{ |
40
|
|
|
self::assertSame([], $this->driver->getExcludePaths()); |
41
|
|
|
|
42
|
|
|
$this->driver->addExcludePaths(['/test/path1', '/test/path2']); |
43
|
|
|
|
44
|
|
|
self::assertSame([ |
45
|
|
|
'/test/path1', |
46
|
|
|
'/test/path2', |
47
|
|
|
], $this->driver->getExcludePaths()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testGetReader() : void |
51
|
|
|
{ |
52
|
|
|
self::assertSame($this->reader, $this->driver->getReader()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testGetSetFileExtension() : void |
56
|
|
|
{ |
57
|
|
|
self::assertSame('.php', $this->driver->getFileExtension()); |
58
|
|
|
|
59
|
|
|
$this->driver->setFileExtension('.php1'); |
60
|
|
|
|
61
|
|
|
self::assertSame('.php1', $this->driver->getFileExtension()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testGetAllClassNames() : void |
65
|
|
|
{ |
66
|
|
|
$classes = $this->driver->getAllClassNames(); |
67
|
|
|
|
68
|
|
|
self::assertSame([TestClass::class], $classes); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testIsTransient() : void |
72
|
|
|
{ |
73
|
|
|
self::assertTrue($this->driver->isTransient(TestObject::class)); |
74
|
|
|
|
75
|
|
|
self::assertFalse($this->driver->isTransient(IsTransientTest::class)); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
protected function setUp() : void |
79
|
|
|
{ |
80
|
|
|
$this->reader = new AnnotationReader(); |
81
|
|
|
|
82
|
|
|
$this->driver = new SimpleAnnotationDriver( |
83
|
|
|
$this->reader, |
84
|
|
|
[__DIR__ . '/_files/annotation'] |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
class SimpleAnnotationDriver extends AnnotationDriver |
90
|
|
|
{ |
91
|
|
|
/** @var array<string, int> */ |
92
|
|
|
protected $entityAnnotationClasses = [Entity::class => 1]; |
93
|
|
|
|
94
|
|
|
public function loadMetadataForClass(string $className, ClassMetadata $metadata) : void |
95
|
|
|
{ |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @Entity |
101
|
|
|
*/ |
102
|
|
|
class IsTransientTest |
103
|
|
|
{ |
104
|
|
|
} |
105
|
|
|
|