| @@ 401-451 (lines=51) @@ | ||
| 398 | /** |
|
| 399 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem |
|
| 400 | */ |
|
| 401 | public function testDeleteTrashItemNoMoreLocations() |
|
| 402 | { |
|
| 403 | $handler = $this->getTrashHandler(); |
|
| 404 | ||
| 405 | $this->locationGateway |
|
| 406 | ->expects($this->once()) |
|
| 407 | ->method('loadTrashByLocation') |
|
| 408 | ->with(69) |
|
| 409 | ->will( |
|
| 410 | $this->returnValue( |
|
| 411 | [ |
|
| 412 | 'node_id' => 69, |
|
| 413 | 'contentobject_id' => 67, |
|
| 414 | 'path_string' => '/1/2/69', |
|
| 415 | ] |
|
| 416 | ) |
|
| 417 | ); |
|
| 418 | ||
| 419 | $this->locationMapper |
|
| 420 | ->expects($this->once()) |
|
| 421 | ->method('createLocationFromRow') |
|
| 422 | ->will( |
|
| 423 | $this->returnValue( |
|
| 424 | new Trashed( |
|
| 425 | [ |
|
| 426 | 'id' => 69, |
|
| 427 | 'contentId' => 67, |
|
| 428 | 'pathString' => '/1/2/69', |
|
| 429 | ] |
|
| 430 | ) |
|
| 431 | ) |
|
| 432 | ); |
|
| 433 | ||
| 434 | $this->locationGateway |
|
| 435 | ->expects($this->once()) |
|
| 436 | ->method('removeElementFromTrash') |
|
| 437 | ->with(69); |
|
| 438 | ||
| 439 | $this->locationGateway |
|
| 440 | ->expects($this->once()) |
|
| 441 | ->method('countLocationsByContentId') |
|
| 442 | ->with(67) |
|
| 443 | ->will($this->returnValue(0)); |
|
| 444 | ||
| 445 | $this->contentHandler |
|
| 446 | ->expects($this->once()) |
|
| 447 | ->method('deleteContent') |
|
| 448 | ->with(67); |
|
| 449 | ||
| 450 | $handler->deleteTrashItem(69); |
|
| 451 | } |
|
| 452 | ||
| 453 | /** |
|
| 454 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem |
|
| @@ 456-505 (lines=50) @@ | ||
| 453 | /** |
|
| 454 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem |
|
| 455 | */ |
|
| 456 | public function testDeleteTrashItemStillHaveLocations() |
|
| 457 | { |
|
| 458 | $handler = $this->getTrashHandler(); |
|
| 459 | ||
| 460 | $this->locationGateway |
|
| 461 | ->expects($this->once()) |
|
| 462 | ->method('loadTrashByLocation') |
|
| 463 | ->with(69) |
|
| 464 | ->will( |
|
| 465 | $this->returnValue( |
|
| 466 | [ |
|
| 467 | 'node_id' => 69, |
|
| 468 | 'contentobject_id' => 67, |
|
| 469 | 'path_string' => '/1/2/69', |
|
| 470 | ] |
|
| 471 | ) |
|
| 472 | ); |
|
| 473 | ||
| 474 | $this->locationMapper |
|
| 475 | ->expects($this->once()) |
|
| 476 | ->method('createLocationFromRow') |
|
| 477 | ->will( |
|
| 478 | $this->returnValue( |
|
| 479 | new Trashed( |
|
| 480 | [ |
|
| 481 | 'id' => 69, |
|
| 482 | 'contentId' => 67, |
|
| 483 | 'pathString' => '/1/2/69', |
|
| 484 | ] |
|
| 485 | ) |
|
| 486 | ) |
|
| 487 | ); |
|
| 488 | ||
| 489 | $this->locationGateway |
|
| 490 | ->expects($this->once()) |
|
| 491 | ->method('removeElementFromTrash') |
|
| 492 | ->with(69); |
|
| 493 | ||
| 494 | $this->locationGateway |
|
| 495 | ->expects($this->once()) |
|
| 496 | ->method('countLocationsByContentId') |
|
| 497 | ->with(67) |
|
| 498 | ->will($this->returnValue(1)); |
|
| 499 | ||
| 500 | $this->contentHandler |
|
| 501 | ->expects($this->never()) |
|
| 502 | ->method('deleteContent'); |
|
| 503 | ||
| 504 | $handler->deleteTrashItem(69); |
|
| 505 | } |
|
| 506 | } |
|
| 507 | ||