function testTwoNodes()
 {
     $user = new User();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("ouhosu");
     $this->em->persist($user);
     $tree = new Tree();
     $tree->setTitleAdmin('Tree');
     $tree->setPublicId('tree');
     $tree->setOwner($user);
     $this->em->persist($tree);
     $treeVersion = new TreeVersion();
     $treeVersion->setTree($tree);
     $treeVersion->setPublicId('version');
     $this->em->persist($treeVersion);
     $startNode = new Node();
     $startNode->setTreeVersion($treeVersion);
     $startNode->setPublicId('start');
     $this->em->persist($startNode);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setPublicId('end');
     $this->em->persist($endNode);
     $nodeOption = new NodeOption();
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($startNode);
     $nodeOption->setDestinationNode($endNode);
     $nodeOption->setPublicId('option');
     $this->em->persist($nodeOption);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $this->em->flush();
     // TEST
     $process = new GetUnreachableBitsOfTree($this->em, $treeVersion);
     $process->go();
     $unreachableNodes = $process->getUnreachableNodes();
     $this->assertEquals(0, count($unreachableNodes));
 }
 function testTwoNodesInLoop()
 {
     $user = new User();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("ouhosu");
     $this->em->persist($user);
     $tree = new Tree();
     $tree->setTitleAdmin('Tree');
     $tree->setPublicId('tree');
     $tree->setOwner($user);
     $this->em->persist($tree);
     $treeVersion = new TreeVersion();
     $treeVersion->setTree($tree);
     $treeVersion->setPublicId('version');
     $this->em->persist($treeVersion);
     $nodeA = new Node();
     $nodeA->setTreeVersion($treeVersion);
     $nodeA->setPublicId('start');
     $this->em->persist($nodeA);
     $nodeB = new Node();
     $nodeB->setTreeVersion($treeVersion);
     $nodeB->setPublicId('end');
     $this->em->persist($nodeB);
     $nodeAtoB = new NodeOption();
     $nodeAtoB->setTreeVersion($treeVersion);
     $nodeAtoB->setNode($nodeA);
     $nodeAtoB->setDestinationNode($nodeB);
     $nodeAtoB->setPublicId('option1');
     $this->em->persist($nodeAtoB);
     $nodeBtoA = new NodeOption();
     $nodeBtoA->setTreeVersion($treeVersion);
     $nodeBtoA->setNode($nodeB);
     $nodeBtoA->setDestinationNode($nodeA);
     $nodeBtoA->setPublicId('option2');
     $this->em->persist($nodeBtoA);
     $this->em->flush();
     // TEST
     $process = new GetUnreachableBitsOfTree($this->em, $treeVersion);
     $process->go();
     $unreachableNodes = $process->getUnreachableNodes();
     $this->assertEquals(2, count($unreachableNodes));
     $unreachableNode = $unreachableNodes[0];
     $this->assertEquals($nodeA->getId(), $unreachableNode->getId());
     $unreachableNode = $unreachableNodes[1];
     $this->assertEquals($nodeB->getId(), $unreachableNode->getId());
 }
 public function nodeListUnreacheableNodesAction($treeId, $versionId)
 {
     // build
     $return = $this->build($treeId, $versionId);
     //data
     $process = new GetUnreachableBitsOfTree($this->getDoctrine(), $this->treeVersion);
     $process->go();
     $nodes = $process->getUnreachableNodes();
     return $this->render('QuestionKeyBundle:AdminTreeVersion:nodeListUnreachableNodes.html.twig', array('tree' => $this->tree, 'treeVersion' => $this->treeVersion, 'nodes' => $nodes));
 }