@@ 146-207 (lines=62) @@ | ||
143 | parent::setUp(); |
|
144 | } |
|
145 | ||
146 | public function testAct() |
|
147 | { |
|
148 | $location = new Location(array( |
|
149 | 'contentInfo' => new ContentInfo(array( |
|
150 | 'id' => 123, |
|
151 | )), |
|
152 | )); |
|
153 | ||
154 | $content = new Content(array( |
|
155 | 'internalFields' => $this->fields, |
|
156 | 'versionInfo' => new VersionInfo(array( |
|
157 | 'contentInfo' => new ContentInfo(array( |
|
158 | 'mainLanguageCode' => 'eng_GB', |
|
159 | )), |
|
160 | )), |
|
161 | )); |
|
162 | ||
163 | $dataWrapper = new DataWrapper($this->struct, $this->contentType, $location); |
|
164 | $event = new InformationCollected($dataWrapper); |
|
165 | ||
166 | $user = new User(array( |
|
167 | 'content' => new Content(array( |
|
168 | 'versionInfo' => new VersionInfo(array( |
|
169 | 'contentInfo' => new ContentInfo(array( |
|
170 | 'id' => 123, |
|
171 | )), |
|
172 | )), |
|
173 | )), |
|
174 | 'login' => 'login', |
|
175 | )); |
|
176 | ||
177 | $ezInfoCollection = new EzInfoCollection(); |
|
178 | $ezInfoCollectionAttribute = new EzInfoCollectionAttribute(); |
|
179 | ||
180 | $this->ezRepository->expects($this->once()) |
|
181 | ->method('getContentService') |
|
182 | ->willReturn($this->contentService); |
|
183 | ||
184 | $this->contentService->expects($this->once()) |
|
185 | ->method('loadContent') |
|
186 | ->with(123) |
|
187 | ->willReturn($content); |
|
188 | ||
189 | $this->ezRepository->expects($this->once()) |
|
190 | ->method('getCurrentUser') |
|
191 | ->willReturn($user); |
|
192 | ||
193 | $this->repository->expects($this->once()) |
|
194 | ->method('createMain') |
|
195 | ->willReturn($ezInfoCollection); |
|
196 | ||
197 | $this->factory->expects($this->exactly(3)) |
|
198 | ->method('getLegacyValue') |
|
199 | ->withAnyParameters() |
|
200 | ->willReturn($this->legacyData); |
|
201 | ||
202 | $this->repository->expects($this->exactly(3)) |
|
203 | ->method('createChild') |
|
204 | ->willReturn($ezInfoCollectionAttribute); |
|
205 | ||
206 | $this->action->act($event); |
|
207 | } |
|
208 | ||
209 | /** |
|
210 | * @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException |
|
@@ 274-335 (lines=62) @@ | ||
271 | /** |
|
272 | * @expectedException \Netgen\Bundle\InformationCollectionBundle\Exception\ActionFailedException |
|
273 | */ |
|
274 | public function testActWithExceptionOnInformationCollectionAttributeRepository() |
|
275 | { |
|
276 | $location = new Location(array( |
|
277 | 'contentInfo' => new ContentInfo(array( |
|
278 | 'id' => 123, |
|
279 | )), |
|
280 | )); |
|
281 | ||
282 | $content = new Content(array( |
|
283 | 'internalFields' => $this->fields, |
|
284 | 'versionInfo' => new VersionInfo(array( |
|
285 | 'contentInfo' => new ContentInfo(array( |
|
286 | 'mainLanguageCode' => 'eng_GB', |
|
287 | )), |
|
288 | )), |
|
289 | )); |
|
290 | ||
291 | $dataWrapper = new DataWrapper($this->struct, $this->contentType, $location); |
|
292 | $event = new InformationCollected($dataWrapper); |
|
293 | ||
294 | $user = new User(array( |
|
295 | 'content' => new Content(array( |
|
296 | 'versionInfo' => new VersionInfo(array( |
|
297 | 'contentInfo' => new ContentInfo(array( |
|
298 | 'id' => 123, |
|
299 | )), |
|
300 | )), |
|
301 | )), |
|
302 | 'login' => 'login', |
|
303 | )); |
|
304 | ||
305 | $ezInfoCollection = new EzInfoCollection(); |
|
306 | $ezInfoCollectionAttribute = new EzInfoCollectionAttribute(); |
|
307 | ||
308 | $this->ezRepository->expects($this->once()) |
|
309 | ->method('getContentService') |
|
310 | ->willReturn($this->contentService); |
|
311 | ||
312 | $this->contentService->expects($this->once()) |
|
313 | ->method('loadContent') |
|
314 | ->with(123) |
|
315 | ->willReturn($content); |
|
316 | ||
317 | $this->ezRepository->expects($this->once()) |
|
318 | ->method('getCurrentUser') |
|
319 | ->willReturn($user); |
|
320 | ||
321 | $this->repository->expects($this->once()) |
|
322 | ->method('createMain') |
|
323 | ->willReturn($ezInfoCollection); |
|
324 | ||
325 | $this->factory->expects($this->exactly(1)) |
|
326 | ->method('getLegacyValue') |
|
327 | ->withAnyParameters() |
|
328 | ->willReturn($this->legacyData); |
|
329 | ||
330 | $this->repository->expects($this->once()) |
|
331 | ->method('createChild') |
|
332 | ->willThrowException(new DBALException()); |
|
333 | ||
334 | $this->action->act($event); |
|
335 | } |
|
336 | } |
|
337 |