public function testCanGetModifiedNodesRecursively()
{
$comp_subtree_mock = M::mock('Gittern\\Entity\\GitObject\\Tree');
$comp_tree_node = M::mock('Gittern\\Entity\\GitObject\\Node\\TreeNode', array('getName' => 'foobaz', 'getTree' => $comp_subtree_mock));
$base_subtree_mock = M::mock('Gittern\\Entity\\GitObject\\Tree');
$base_tree_node = M::mock('Gittern\\Entity\\GitObject\\Node\\TreeNode', array('getName' => 'foobaz', 'getTree' => $base_subtree_mock));
$node1_a = M::mock(array('getName' => 'foobar'));
$node1_b = M::mock(array('getName' => 'foobar'));
$node2_a = M::mock(array('getName' => 'foo'));
$node2_b = M::mock(array('getName' => 'foo'));
$node3 = M::mock(array('getName' => 'bork'));
$node1_a->shouldReceive('equals')->with($node1_b)->andReturn(false)->once()->atLeast();
$node2_a->shouldReceive('equals')->with($node2_b)->andReturn(false)->once()->atLeast();
$base_tree_node->shouldReceive('equals')->with($comp_tree_node)->andReturn(false)->once()->atLeast();
$node3->shouldReceive('equals')->with($node3)->andReturn(true)->once()->atLeast();
$this->base_tree_mock->shouldReceive('hasNodeNamed')->with('bork')->andReturn(true)->once()->atLeast();
$this->base_tree_mock->shouldReceive('getNodeNamed')->with('bork')->andReturn($node3)->once()->atLeast();
$this->base_tree_mock->shouldReceive('hasNodeNamed')->with('foobar')->andReturn(true)->once()->atLeast();
$this->base_tree_mock->shouldReceive('getNodeNamed')->with('foobar')->andReturn($node1_a)->once()->atLeast();
$this->base_tree_mock->shouldReceive('hasNodeNamed')->with('foobaz')->andReturn(true)->once()->atLeast();
$this->base_tree_mock->shouldReceive('getNodeNamed')->with('foobaz')->andReturn($base_tree_node);
$this->comp_tree_mock->shouldReceive('getNodes')->andReturn(array($node3, $node1_b, $comp_tree_node));
$base_subtree_mock->shouldReceive('hasNodeNamed')->with('foo')->andReturn(true)->once()->atLeast();
$base_subtree_mock->shouldReceive('getNodeNamed')->with('foo')->andReturn($node2_a)->once()->atLeast();
$comp_subtree_mock->shouldReceive('getNodes')->andReturn(array($node2_b));
$this->assertEquals(array('foobar' => $node1_b, 'foobaz/foo' => $node2_b), $this->diff->getModifiedLeafNodesRecursive());
}