| @@ 326-359 (lines=34) @@ | ||
| 323 | * @depends testConstructor |
|
| 324 | * @covers \eZ\Publish\Core\Repository\URLWildcardService::remove |
|
| 325 | */ |
|
| 326 | public function testRemove() |
|
| 327 | { |
|
| 328 | $wildcard = new URLWildcard(['id' => 'McBomb']); |
|
| 329 | ||
| 330 | $mockedService = $this->getPartlyMockedURLWildcardService(); |
|
| 331 | /** @var \PHPUnit\Framework\MockObject\MockObject $handlerMock */ |
|
| 332 | $handlerMock = $this->getPersistenceMock()->urlWildcardHandler(); |
|
| 333 | $repositoryMock = $this->getRepositoryMock(); |
|
| 334 | ||
| 335 | $repositoryMock->expects( |
|
| 336 | $this->once() |
|
| 337 | )->method( |
|
| 338 | 'canUser' |
|
| 339 | )->with( |
|
| 340 | $this->equalTo('content'), |
|
| 341 | $this->equalTo('urltranslator'), |
|
| 342 | $this->equalTo($wildcard) |
|
| 343 | )->will( |
|
| 344 | $this->returnValue(true) |
|
| 345 | ); |
|
| 346 | ||
| 347 | $repositoryMock->expects($this->once())->method('beginTransaction'); |
|
| 348 | $repositoryMock->expects($this->once())->method('commit'); |
|
| 349 | ||
| 350 | $handlerMock->expects( |
|
| 351 | $this->once() |
|
| 352 | )->method( |
|
| 353 | 'remove' |
|
| 354 | )->with( |
|
| 355 | $this->equalTo('McBomb') |
|
| 356 | ); |
|
| 357 | ||
| 358 | $mockedService->remove($wildcard); |
|
| 359 | } |
|
| 360 | ||
| 361 | /** |
|
| 362 | * Test for the remove() method. |
|
| @@ 368-403 (lines=36) @@ | ||
| 365 | * @covers \eZ\Publish\Core\Repository\URLWildcardService::remove |
|
| 366 | * @expectedException \Exception |
|
| 367 | */ |
|
| 368 | public function testRemoveWithRollback() |
|
| 369 | { |
|
| 370 | $wildcard = new URLWildcard(['id' => 'McBoo']); |
|
| 371 | ||
| 372 | $mockedService = $this->getPartlyMockedURLWildcardService(); |
|
| 373 | /** @var \PHPUnit\Framework\MockObject\MockObject $handlerMock */ |
|
| 374 | $handlerMock = $this->getPersistenceMock()->urlWildcardHandler(); |
|
| 375 | $repositoryMock = $this->getRepositoryMock(); |
|
| 376 | ||
| 377 | $repositoryMock->expects( |
|
| 378 | $this->once() |
|
| 379 | )->method( |
|
| 380 | 'canUser' |
|
| 381 | )->with( |
|
| 382 | $this->equalTo('content'), |
|
| 383 | $this->equalTo('urltranslator'), |
|
| 384 | $this->equalTo($wildcard) |
|
| 385 | )->will( |
|
| 386 | $this->returnValue(true) |
|
| 387 | ); |
|
| 388 | ||
| 389 | $repositoryMock->expects($this->once())->method('beginTransaction'); |
|
| 390 | $repositoryMock->expects($this->once())->method('rollback'); |
|
| 391 | ||
| 392 | $handlerMock->expects( |
|
| 393 | $this->once() |
|
| 394 | )->method( |
|
| 395 | 'remove' |
|
| 396 | )->with( |
|
| 397 | $this->equalTo('McBoo') |
|
| 398 | )->will( |
|
| 399 | $this->throwException(new \Exception()) |
|
| 400 | ); |
|
| 401 | ||
| 402 | $mockedService->remove($wildcard); |
|
| 403 | } |
|
| 404 | ||
| 405 | /** |
|
| 406 | * Test for the load() method. |
|