|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ExtRefFieldsCompilerPassTest class file |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Graviton\DocumentBundle\Tests\DependencyInjection\CompilerPass; |
|
7
|
|
|
|
|
8
|
|
|
use Graviton\DocumentBundle\DependencyInjection\Compiler\ExtRefFieldsCompilerPass; |
|
9
|
|
|
use Graviton\DocumentBundle\DependencyInjection\Compiler\Utils\DocumentMap; |
|
10
|
|
|
use Symfony\Component\Finder\Finder; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
14
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
15
|
|
|
* @link http://swisscom.ch |
|
16
|
|
|
*/ |
|
17
|
|
|
class ExtRefFieldsCompilerPassTest extends \PHPUnit_Framework_TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
public function testProcess() |
|
23
|
|
|
{ |
|
24
|
|
|
$serviceDouble = $this |
|
25
|
|
|
->getMockBuilder('Symfony\\Component\\DependencyInjection\\Definition') |
|
26
|
|
|
->disableOriginalConstructor() |
|
27
|
|
|
->setMethods(['getTag']) |
|
28
|
|
|
->getMock(); |
|
29
|
|
|
$serviceDouble |
|
30
|
|
|
->expects($this->once()) |
|
31
|
|
|
->method('getTag') |
|
32
|
|
|
->with('graviton.rest') |
|
33
|
|
|
->willReturn([]); |
|
34
|
|
|
|
|
35
|
|
|
$containerDouble = $this |
|
36
|
|
|
->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder') |
|
37
|
|
|
->disableOriginalConstructor() |
|
38
|
|
|
->getMock(); |
|
39
|
|
|
$containerDouble |
|
40
|
|
|
->expects($this->once()) |
|
41
|
|
|
->method('findTaggedServiceIds') |
|
42
|
|
|
->with('graviton.rest') |
|
43
|
|
|
->willReturn(['gravitonTest.document.controller.A' => []]); |
|
44
|
|
|
$containerDouble |
|
45
|
|
|
->expects($this->once()) |
|
46
|
|
|
->method('getDefinition') |
|
47
|
|
|
->with('gravitonTest.document.controller.A') |
|
48
|
|
|
->willReturn($serviceDouble); |
|
49
|
|
|
$containerDouble |
|
50
|
|
|
->expects($this->once()) |
|
51
|
|
|
->method('setParameter') |
|
52
|
|
|
->with( |
|
53
|
|
|
$this->equalTo('graviton.document.extref.fields'), |
|
54
|
|
|
[ |
|
55
|
|
|
'gravitontest.document.rest.a.get' => [ |
|
56
|
|
|
'$exposedRefA', |
|
57
|
|
|
|
|
58
|
|
|
'achild.$exposedRefB', |
|
59
|
|
|
'achild.bchild.$exposedRefC', |
|
60
|
|
|
'achild.bchildren.0.$exposedRefC', |
|
61
|
|
|
|
|
62
|
|
|
'achildren.0.$exposedRefB', |
|
63
|
|
|
'achildren.0.bchild.$exposedRefC', |
|
64
|
|
|
'achildren.0.bchildren.0.$exposedRefC', |
|
65
|
|
|
], |
|
66
|
|
|
'gravitontest.document.rest.a.all' => [ |
|
67
|
|
|
'$exposedRefA', |
|
68
|
|
|
|
|
69
|
|
|
'achild.$exposedRefB', |
|
70
|
|
|
'achild.bchild.$exposedRefC', |
|
71
|
|
|
'achild.bchildren.0.$exposedRefC', |
|
72
|
|
|
|
|
73
|
|
|
'achildren.0.$exposedRefB', |
|
74
|
|
|
'achildren.0.bchild.$exposedRefC', |
|
75
|
|
|
'achildren.0.bchildren.0.$exposedRefC', |
|
76
|
|
|
], |
|
77
|
|
|
] |
|
78
|
|
|
); |
|
79
|
|
|
|
|
80
|
|
|
$documentMap = new DocumentMap( |
|
81
|
|
|
(new Finder()) |
|
82
|
|
|
->in(__DIR__.'/Resources/doctrine/extref') |
|
83
|
|
|
->name('*.mongodb.xml'), |
|
84
|
|
|
(new Finder()) |
|
85
|
|
|
->in(__DIR__.'/Resources/serializer/extref') |
|
86
|
|
|
->name('*.xml'), |
|
87
|
|
|
(new Finder()) |
|
88
|
|
|
->in(__DIR__.'/Resources/validation/extref') |
|
89
|
|
|
->name('*.xml'), |
|
90
|
|
|
(new Finder()) |
|
91
|
|
|
->in(__DIR__.'/Resources/schema') |
|
92
|
|
|
->name('*.json') |
|
93
|
|
|
); |
|
94
|
|
|
|
|
95
|
|
|
$compilerPass = new ExtRefFieldsCompilerPass($documentMap); |
|
96
|
|
|
$compilerPass->process($containerDouble); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|