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