eZ\Publish\Core\Persistence\Legacy\Tests\Content\TreeHandlerTest::testRemoveSubtree PHP Method

testRemoveSubtree() public method

public testRemoveSubtree ( )
    public function testRemoveSubtree()
    {
        $treeHandler = $this->getPartlyMockedTreeHandler(array('changeMainLocation', 'removeRawContent'));
        // Original call
        $this->getLocationGatewayMock()->expects($this->at(0))->method('getBasicNodeData')->with(42)->will($this->returnValue(array('contentobject_id' => 100, 'main_node_id' => 200)));
        $this->getLocationGatewayMock()->expects($this->at(1))->method('getChildren')->with(42)->will($this->returnValue(array(array('node_id' => 201), array('node_id' => 202))));
        // First recursive call
        $this->getLocationGatewayMock()->expects($this->at(2))->method('getBasicNodeData')->with(201)->will($this->returnValue(array('contentobject_id' => 101, 'main_node_id' => 201)));
        $this->getLocationGatewayMock()->expects($this->at(3))->method('getChildren')->with(201)->will($this->returnValue(array()));
        $this->getLocationGatewayMock()->expects($this->at(4))->method('countLocationsByContentId')->with(101)->will($this->returnValue(1));
        $treeHandler->expects($this->once())->method('removeRawContent')->with(101);
        $this->getLocationGatewayMock()->expects($this->at(5))->method('removeLocation')->with(201);
        $this->getLocationGatewayMock()->expects($this->at(6))->method('deleteNodeAssignment')->with(101);
        // Second recursive call
        $this->getLocationGatewayMock()->expects($this->at(7))->method('getBasicNodeData')->with(202)->will($this->returnValue(array('contentobject_id' => 102, 'main_node_id' => 202)));
        $this->getLocationGatewayMock()->expects($this->at(8))->method('getChildren')->with(202)->will($this->returnValue(array()));
        $this->getLocationGatewayMock()->expects($this->at(9))->method('countLocationsByContentId')->with(102)->will($this->returnValue(2));
        $this->getLocationGatewayMock()->expects($this->at(10))->method('getFallbackMainNodeData')->with(102, 202)->will($this->returnValue(array('node_id' => 203, 'contentobject_version' => 1, 'parent_node_id' => 204)));
        $treeHandler->expects($this->once())->method('changeMainLocation')->with(102, 203, 1, 204);
        $this->getLocationGatewayMock()->expects($this->at(11))->method('removeLocation')->with(202);
        $this->getLocationGatewayMock()->expects($this->at(12))->method('deleteNodeAssignment')->with(102);
        // Continuation of the original call
        $this->getLocationGatewayMock()->expects($this->at(13))->method('removeLocation')->with(42);
        $this->getLocationGatewayMock()->expects($this->at(14))->method('deleteNodeAssignment')->with(100);
        // Start
        $treeHandler->removeSubtree(42);
    }