eZ\Publish\Core\Persistence\Legacy\Tests\Content\Location\TrashHandlerTest::testTrashSubtreeUpdatesMainLocation PHP Method

testTrashSubtreeUpdatesMainLocation() public method

    public function testTrashSubtreeUpdatesMainLocation()
    {
        $handler = $this->getTrashHandler();
        $this->locationGateway->expects($this->at(0))->method('getSubtreeContent')->with(20)->will($this->returnValue(array(array('contentobject_id' => 10, 'node_id' => 20, 'main_node_id' => 30, 'parent_node_id' => 40), array('contentobject_id' => 11, 'node_id' => 21, 'main_node_id' => 21, 'parent_node_id' => 41))));
        $this->locationGateway->expects($this->at(1))->method('countLocationsByContentId')->with(10)->will($this->returnValue(1));
        $this->locationGateway->expects($this->at(2))->method('trashLocation')->with(20);
        $this->locationGateway->expects($this->at(3))->method('countLocationsByContentId')->with(11)->will($this->returnValue(2));
        $this->locationGateway->expects($this->at(4))->method('removeLocation')->with(21);
        $this->locationGateway->expects($this->at(5))->method('getFallbackMainNodeData')->with(11, 21)->will($this->returnValue(array('node_id' => 100, 'contentobject_version' => 101, 'parent_node_id' => 102)));
        $this->locationHandler->expects($this->once())->method('changeMainLocation')->with(11, 100, 101, 102);
        $this->locationHandler->expects($this->once())->method('markSubtreeModified')->with(40);
        $this->locationGateway->expects($this->at(6))->method('loadTrashByLocation')->with(20)->will($this->returnValue($array = array('data…')));
        $this->locationMapper->expects($this->once())->method('createLocationFromRow')->with($array, null, new Trashed())->will($this->returnValue(new Trashed(array('id' => 20))));
        $trashedObject = $handler->trashSubtree(20);
        self::assertInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Trashed', $trashedObject);
        self::assertSame(20, $trashedObject->id);
    }