@@ 103-144 (lines=42) @@ | ||
100 | ); |
|
101 | } |
|
102 | ||
103 | public function testLookForPathFromStartEntityToDestination() |
|
104 | { |
|
105 | $this->samepleJson = [ |
|
106 | "AppBundle\\Entity\\Root" => [ |
|
107 | "relations" => [ |
|
108 | "foo" => "AppBundle\\Entity\\Foo", |
|
109 | ] |
|
110 | ], |
|
111 | "AppBundle\\Entity\\Foo" => [ |
|
112 | "relations" => [ |
|
113 | "bar" => "AppBundle\\Entity\\Bar", |
|
114 | ] |
|
115 | ], |
|
116 | "AppBundle\\Entity\\Bar" => [ |
|
117 | "relations" => [ |
|
118 | "fizz" => "AppBundle\\Entity\\Fizz", |
|
119 | ] |
|
120 | ], |
|
121 | ]; |
|
122 | ||
123 | $this->mapper = $this |
|
124 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\RelationDatamapper') |
|
125 | ->disableOriginalConstructor() |
|
126 | ->getMock(); |
|
127 | ||
128 | $this->mapper->expects($this->once()) |
|
129 | ->method('getMap') |
|
130 | ->will($this->returnValue( |
|
131 | $this->samepleJson |
|
132 | )); |
|
133 | ||
134 | $this->pathFinder = new JsonPathFinder( |
|
135 | $this->mapper |
|
136 | ); |
|
137 | ||
138 | $this->pathFinder->setEntity("AppBundle\\Entity\\Root"); |
|
139 | ||
140 | $this->assertEquals( |
|
141 | "foo.bar.fizz", |
|
142 | $this->pathFinder->getPathTo("AppBundle\\Entity\\Fizz") |
|
143 | ); |
|
144 | } |
|
145 | ||
146 | public function testBuildPathBetweenTwoEntities() |
|
147 | { |
|
@@ 146-187 (lines=42) @@ | ||
143 | ); |
|
144 | } |
|
145 | ||
146 | public function testBuildPathBetweenTwoEntities() |
|
147 | { |
|
148 | $this->samepleJson = [ |
|
149 | "GammaBundle\\Entity\\Item" => [ |
|
150 | "relations" => [ |
|
151 | "items" => "AppBundle\\Entity\\Foo", |
|
152 | ] |
|
153 | ], |
|
154 | "AppBundle\\Entity\\Foo" => [ |
|
155 | "relations" => [ |
|
156 | "item" => "ZarroBundle\\Entity\\Item", |
|
157 | ] |
|
158 | ], |
|
159 | "ZarroBundle\\Entity\\Item" => [ |
|
160 | "relations" => [ |
|
161 | "family" => "AppBundle\\Entity\\Family", |
|
162 | ] |
|
163 | ], |
|
164 | ]; |
|
165 | ||
166 | $this->mapper = $this |
|
167 | ->getMockBuilder('Mado\QueryBundle\Component\Meta\RelationDatamapper') |
|
168 | ->disableOriginalConstructor() |
|
169 | ->getMock(); |
|
170 | ||
171 | $this->mapper->expects($this->once()) |
|
172 | ->method('getMap') |
|
173 | ->will($this->returnValue( |
|
174 | $this->samepleJson |
|
175 | )); |
|
176 | ||
177 | $this->pathFinder = new JsonPathFinder( |
|
178 | $this->mapper |
|
179 | ); |
|
180 | ||
181 | $this->pathFinder->setQueryStartEntity("GammaBundle\\Entity\\Item"); |
|
182 | ||
183 | $this->assertEquals( |
|
184 | "_embedded.items.item.family", |
|
185 | $this->pathFinder->getPathToEntity("AppBundle\\Entity\\Family") |
|
186 | ); |
|
187 | } |
|
188 | ||
189 | /** |
|
190 | * @expectedException \Mado\QueryBundle\Component\Meta\Exceptions\UnreachablePathException |