public function createNodeWithAutoCreatedChildNodesAndNoIdentifierUsesGeneratedIdentifierOfNodeForChildNodes()
{
$mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$mockContext->expects($this->any())->method('getTargetDimensions')->will($this->returnValue(array('language' => 'mul_ZZ')));
$mockFirstLevelNodeCache = $this->createMock(FirstLevelNodeCache::class);
$mockContext->expects($this->any())->method('getFirstLevelNodeCache')->will($this->returnValue($mockFirstLevelNodeCache));
$mockNodeData = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
$mockNodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock();
$mockSubNodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock();
$mockNodeType->expects($this->any())->method('getDefaultValuesForProperties')->will($this->returnValue(array()));
$mockNodeType->expects($this->any())->method('getAutoCreatedChildNodes')->will($this->returnValue(array('subnode1' => $mockSubNodeType)));
$i = 0;
$generatedIdentifiers = array();
$node = $this->getMockBuilder(Node::class)->setMethods(array('createSingleNode'))->setConstructorArgs(array($mockNodeData, $mockContext))->getMock();
$node->expects($this->any())->method('createSingleNode')->will($this->returnCallback(function () use(&$i, &$generatedIdentifiers, $mockSubNodeType) {
$newNode = $this->createMock(NodeInterface::class);
$newNode->expects($this->any())->method('getIdentifier')->will($this->returnValue('node-' . $i++));
$newNode->expects($this->once())->method('createNode')->with('subnode1', $mockSubNodeType, $this->callback(function ($identifier) use(&$generatedIdentifiers, $i) {
$generatedIdentifiers[$i] = $identifier;
return true;
}));
return $newNode;
}));
$node->createNode('foo', $mockNodeType);
$node->createNode('bar', $mockNodeType);
$this->assertNotSame($generatedIdentifiers[1], $generatedIdentifiers[2], 'Child nodes should have distinct identifiers');
}