protected function assertThatOriginalOrNewNodeIsCalled($methodName, $argument1 = null)
{
$propertyMapper = $this->getMockBuilder(PropertyMapper::class)->disableOriginalConstructor()->getMock();
$propertyMapper->expects($this->any())->method('convert')->willReturnArgument(0);
$userWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock();
$liveWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock();
$nodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock();
$nodeType->expects($this->any())->method('getPropertyType')->will($this->returnValue('string'));
$originalNode = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
$originalNode->expects($this->any())->method('getWorkspace')->will($this->returnValue($liveWorkspace));
$originalNode->expects($this->any())->method('getNodeType')->will($this->returnValue($nodeType));
if ($argument1 === null) {
$originalNode->expects($this->any())->method($methodName)->will($this->returnValue('originalNodeResult'));
} else {
$originalNode->expects($this->any())->method($methodName)->with($argument1)->will($this->returnValue('originalNodeResult'));
}
$newNode = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
$newNode->expects($this->any())->method('getWorkspace')->will($this->returnValue($userWorkspace));
$newNode->expects($this->any())->method('getNodeType')->will($this->returnValue($nodeType));
if ($argument1 === null) {
$newNode->expects($this->any())->method($methodName)->will($this->returnValue('newNodeResult'));
} else {
$newNode->expects($this->any())->method($methodName)->with($argument1)->will($this->returnValue('newNodeResult'));
}
$context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$context->expects($this->any())->method('getWorkspace')->will($this->returnValue($userWorkspace));
$contextualizedNode = new Node($originalNode, $context);
$this->inject($contextualizedNode, 'propertyMapper', $propertyMapper);
$this->assertEquals('originalNodeResult', $contextualizedNode->{$methodName}($argument1));
$contextualizedNode = new Node($newNode, $context);
$this->inject($contextualizedNode, 'propertyMapper', $propertyMapper);
$this->assertEquals('newNodeResult', $contextualizedNode->{$methodName}($argument1));
}