| @@ 417-474 (lines=58) @@ | ||
| 414 | /** |
|
| 415 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem |
|
| 416 | */ |
|
| 417 | public function testDeleteTrashItemNoMoreLocations() |
|
| 418 | { |
|
| 419 | $handler = $this->getTrashHandler(); |
|
| 420 | ||
| 421 | $trashItemId = 69; |
|
| 422 | $contentId = 67; |
|
| 423 | $this->locationGateway |
|
| 424 | ->expects($this->once()) |
|
| 425 | ->method('loadTrashByLocation') |
|
| 426 | ->with($trashItemId) |
|
| 427 | ->will( |
|
| 428 | $this->returnValue( |
|
| 429 | array( |
|
| 430 | 'node_id' => $trashItemId, |
|
| 431 | 'contentobject_id' => $contentId, |
|
| 432 | 'path_string' => '/1/2/69', |
|
| 433 | ) |
|
| 434 | ) |
|
| 435 | ); |
|
| 436 | ||
| 437 | $this->locationMapper |
|
| 438 | ->expects($this->once()) |
|
| 439 | ->method('createLocationFromRow') |
|
| 440 | ->will( |
|
| 441 | $this->returnValue( |
|
| 442 | new Trashed( |
|
| 443 | array( |
|
| 444 | 'id' => $trashItemId, |
|
| 445 | 'contentId' => $contentId, |
|
| 446 | 'pathString' => '/1/2/69', |
|
| 447 | ) |
|
| 448 | ) |
|
| 449 | ) |
|
| 450 | ); |
|
| 451 | ||
| 452 | $this->locationGateway |
|
| 453 | ->expects($this->once()) |
|
| 454 | ->method('removeElementFromTrash') |
|
| 455 | ->with($trashItemId); |
|
| 456 | ||
| 457 | $this->locationGateway |
|
| 458 | ->expects($this->once()) |
|
| 459 | ->method('countLocationsByContentId') |
|
| 460 | ->with($contentId) |
|
| 461 | ->will($this->returnValue(0)); |
|
| 462 | ||
| 463 | $this->contentHandler |
|
| 464 | ->expects($this->once()) |
|
| 465 | ->method('deleteContent') |
|
| 466 | ->with($contentId); |
|
| 467 | ||
| 468 | $trashItemDeleteResult = $handler->deleteTrashItem($trashItemId); |
|
| 469 | ||
| 470 | $this->assertInstanceOf(TrashItemDeleteResult::class, $trashItemDeleteResult); |
|
| 471 | $this->assertEquals($trashItemId, $trashItemDeleteResult->trashItemId); |
|
| 472 | $this->assertEquals($contentId, $trashItemDeleteResult->contentId); |
|
| 473 | $this->assertTrue($trashItemDeleteResult->contentRemoved); |
|
| 474 | } |
|
| 475 | ||
| 476 | /** |
|
| 477 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem |
|
| @@ 479-535 (lines=57) @@ | ||
| 476 | /** |
|
| 477 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem |
|
| 478 | */ |
|
| 479 | public function testDeleteTrashItemStillHaveLocations() |
|
| 480 | { |
|
| 481 | $handler = $this->getTrashHandler(); |
|
| 482 | ||
| 483 | $trashItemId = 69; |
|
| 484 | $contentId = 67; |
|
| 485 | $this->locationGateway |
|
| 486 | ->expects($this->once()) |
|
| 487 | ->method('loadTrashByLocation') |
|
| 488 | ->with($trashItemId) |
|
| 489 | ->will( |
|
| 490 | $this->returnValue( |
|
| 491 | array( |
|
| 492 | 'node_id' => $trashItemId, |
|
| 493 | 'contentobject_id' => $contentId, |
|
| 494 | 'path_string' => '/1/2/69', |
|
| 495 | ) |
|
| 496 | ) |
|
| 497 | ); |
|
| 498 | ||
| 499 | $this->locationMapper |
|
| 500 | ->expects($this->once()) |
|
| 501 | ->method('createLocationFromRow') |
|
| 502 | ->will( |
|
| 503 | $this->returnValue( |
|
| 504 | new Trashed( |
|
| 505 | array( |
|
| 506 | 'id' => $trashItemId, |
|
| 507 | 'contentId' => $contentId, |
|
| 508 | 'pathString' => '/1/2/69', |
|
| 509 | ) |
|
| 510 | ) |
|
| 511 | ) |
|
| 512 | ); |
|
| 513 | ||
| 514 | $this->locationGateway |
|
| 515 | ->expects($this->once()) |
|
| 516 | ->method('removeElementFromTrash') |
|
| 517 | ->with($trashItemId); |
|
| 518 | ||
| 519 | $this->locationGateway |
|
| 520 | ->expects($this->once()) |
|
| 521 | ->method('countLocationsByContentId') |
|
| 522 | ->with($contentId) |
|
| 523 | ->will($this->returnValue(1)); |
|
| 524 | ||
| 525 | $this->contentHandler |
|
| 526 | ->expects($this->never()) |
|
| 527 | ->method('deleteContent'); |
|
| 528 | ||
| 529 | $trashItemDeleteResult = $handler->deleteTrashItem($trashItemId); |
|
| 530 | ||
| 531 | $this->assertInstanceOf(TrashItemDeleteResult::class, $trashItemDeleteResult); |
|
| 532 | $this->assertEquals($trashItemId, $trashItemDeleteResult->trashItemId); |
|
| 533 | $this->assertEquals($contentId, $trashItemDeleteResult->contentId); |
|
| 534 | $this->assertFalse($trashItemDeleteResult->contentRemoved); |
|
| 535 | } |
|
| 536 | } |
|
| 537 | ||