|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Cubiche/Metadata component. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) Cubiche |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Cubiche\Core\Metadata\Tests\Units\Locator; |
|
13
|
|
|
|
|
14
|
|
|
use Cubiche\Core\Metadata\Exception\MappingException; |
|
15
|
|
|
use Cubiche\Core\Metadata\Locator\DefaultFileLocator; |
|
16
|
|
|
use Cubiche\Core\Metadata\Locator\FileLocatorInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* DefaultFileLocatorTests class. |
|
20
|
|
|
* |
|
21
|
|
|
* Generated by TestGenerator on 2017-05-16 at 13:17:21. |
|
22
|
|
|
*/ |
|
23
|
|
|
class DefaultFileLocatorTests extends FileLocatorTestCase |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @return FileLocatorInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function createLocator() |
|
29
|
|
|
{ |
|
30
|
|
|
return new DefaultFileLocator([ |
|
31
|
|
|
$this->mappingDirectory => 'Cubiche\Core\Metadata\Tests', |
|
32
|
|
|
__DIR__.'/../../Fixtures/mapping-two' => 'Cubiche\Foo\Bar\Tests', |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Test create. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function testCreate() |
|
40
|
|
|
{ |
|
41
|
|
|
$this |
|
42
|
|
|
->given($separator = '') |
|
43
|
|
|
->then() |
|
44
|
|
|
->exception(function () use ($separator) { |
|
45
|
|
|
new DefaultFileLocator([], $separator); |
|
46
|
|
|
})->isInstanceOf(\InvalidArgumentException::class) |
|
47
|
|
|
; |
|
48
|
|
|
|
|
49
|
|
|
$this |
|
50
|
|
|
->given($locator = $this->createLocator()) |
|
51
|
|
|
->then() |
|
52
|
|
|
->array($locator->prefixes()) |
|
53
|
|
|
->contains('Cubiche\Core\Metadata\Tests') |
|
54
|
|
|
->array($locator->paths()) |
|
55
|
|
|
->contains($this->mappingDirectory) |
|
56
|
|
|
; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Test findMappingFile method. |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testfindMappingFile() |
|
63
|
|
|
{ |
|
64
|
|
|
parent::testfindMappingFile(); |
|
65
|
|
|
|
|
66
|
|
|
$this |
|
67
|
|
|
->given($locator = $this->createLocator()) |
|
68
|
|
|
->then() |
|
69
|
|
|
->variable($locator->findMappingFile('Cubiche\Core\Metadata\Tests\Fixtures\Place', '.xml')) |
|
70
|
|
|
->isNull() |
|
71
|
|
|
; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Test getAllClassNames method. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function testGetAllClassNames() |
|
78
|
|
|
{ |
|
79
|
|
|
parent::testGetAllClassNames(); |
|
80
|
|
|
|
|
81
|
|
|
$this |
|
82
|
|
|
->given( |
|
83
|
|
|
$locator = new DefaultFileLocator([ |
|
84
|
|
|
__DIR__.'/../../Fixtures/InvalidMappingDir' => 'Cubiche\Core\Metadata\Tests', |
|
85
|
|
|
]) |
|
86
|
|
|
) |
|
87
|
|
|
->then() |
|
88
|
|
|
->exception(function () use ($locator) { |
|
89
|
|
|
$locator->getAllClassNames('.xml'); |
|
90
|
|
|
})->isInstanceOf(MappingException::class) |
|
91
|
|
|
; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|