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