public function stacktraceAction($treeId, $versionId, $nodeId) { // build $return = $this->build($treeId, $versionId, $nodeId); //data $process = new GetStackTracesForNode($this->getDoctrine()->getManager(), $this->node); $process->go(); return $this->render('QuestionKeyBundle:AdminTreeVersionNode:stacktrace.html.twig', array('tree' => $this->tree, 'treeVersion' => $this->treeVersion, 'node' => $this->node, 'stackTraces' => $process->getStackTraces())); }
/** * start * / * (1) * / * middle -----(2)---> loop back * \ * (3) * \ * end **/ function testDiamond1() { $user = new User(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("ouhosu"); $this->em->persist($user); $tree = new Tree(); $tree->setTitleAdmin('Tree'); $tree->setOwner($user); $tree->setPublicId('tree'); $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); $middleNode = new Node(); $middleNode->setTreeVersion($treeVersion); $middleNode->setPublicId('middle'); $this->em->persist($middleNode); $endNode = new Node(); $endNode->setTreeVersion($treeVersion); $endNode->setPublicId('end'); $this->em->persist($endNode); $nodeOption1 = new NodeOption(); $nodeOption1->setTreeVersion($treeVersion); $nodeOption1->setNode($startNode); $nodeOption1->setDestinationNode($middleNode); $nodeOption1->setPublicId('no1'); $this->em->persist($nodeOption1); $nodeOption2 = new NodeOption(); $nodeOption2->setTreeVersion($treeVersion); $nodeOption2->setNode($middleNode); $nodeOption2->setDestinationNode($middleNode); $nodeOption2->setPublicId('no2'); $this->em->persist($nodeOption2); $nodeOption3 = new NodeOption(); $nodeOption3->setTreeVersion($treeVersion); $nodeOption3->setNode($middleNode); $nodeOption3->setDestinationNode($endNode); $nodeOption3->setPublicId('no3'); $this->em->persist($nodeOption3); $this->em->flush(); $tvsnRepo = $this->em->getRepository('QuestionKeyBundle:TreeVersionStartingNode'); $tvsnRepo->setAsStartingNode($startNode); $process = new GetStackTracesForNode($this->em, $endNode); $process->go(); $stackTraces = $process->getStackTraces(); $this->assertEquals(2, count($stackTraces)); // #################################################### STACK TRACE 1 $stackTrace = array_shift($stackTraces); $this->assertEquals('78ba40d50aa5b6b171709cdabf3da25a', $stackTrace->getPublicId()); $data = $stackTrace->getData(); $this->assertEquals(3, count($data)); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($startNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption1->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($middleNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption3->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($endNode->getId(), $dataRow['node']->getId()); $this->assertNull($dataRow['nodeOption']); // #################################################### STACK TRACE 2 $stackTrace = array_shift($stackTraces); $this->assertEquals('a3592b8780c8ed8da478f42ea06b160a', $stackTrace->getPublicId()); $data = $stackTrace->getData(); $this->assertEquals(4, count($data)); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($startNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption1->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($middleNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption2->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($middleNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption3->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($endNode->getId(), $dataRow['node']->getId()); $this->assertNull($dataRow['nodeOption']); }
/** * start * / \ * (1) (2) * / \ * left right * \ / * (3) (4) * \ / * end **/ function testDiamond1() { $user = new User(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("ouhosu"); $this->em->persist($user); $tree = new Tree(); $tree->setTitleAdmin('Tree'); $tree->setOwner($user); $tree->setPublicId('tree'); $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); $leftNode = new Node(); $leftNode->setTreeVersion($treeVersion); $leftNode->setPublicId('left'); $this->em->persist($leftNode); $rightNode = new Node(); $rightNode->setTreeVersion($treeVersion); $rightNode->setPublicId('right'); $this->em->persist($rightNode); $endNode = new Node(); $endNode->setTreeVersion($treeVersion); $endNode->setPublicId('end'); $this->em->persist($endNode); $nodeOption1 = new NodeOption(); $nodeOption1->setTreeVersion($treeVersion); $nodeOption1->setNode($startNode); $nodeOption1->setDestinationNode($leftNode); $nodeOption1->setPublicId('no1'); $this->em->persist($nodeOption1); $nodeOption2 = new NodeOption(); $nodeOption2->setTreeVersion($treeVersion); $nodeOption2->setNode($startNode); $nodeOption2->setDestinationNode($rightNode); $nodeOption2->setPublicId('no2'); $this->em->persist($nodeOption2); $nodeOption3 = new NodeOption(); $nodeOption3->setTreeVersion($treeVersion); $nodeOption3->setNode($leftNode); $nodeOption3->setDestinationNode($endNode); $nodeOption3->setPublicId('no3'); $this->em->persist($nodeOption3); $nodeOption4 = new NodeOption(); $nodeOption4->setTreeVersion($treeVersion); $nodeOption4->setNode($rightNode); $nodeOption4->setDestinationNode($endNode); $nodeOption4->setPublicId('no4'); $this->em->persist($nodeOption4); $this->em->flush(); $tvsnRepo = $this->em->getRepository('QuestionKeyBundle:TreeVersionStartingNode'); $tvsnRepo->setAsStartingNode($startNode); $process = new GetStackTracesForNode($this->em, $endNode); $process->go(); $stackTraces = $process->getStackTraces(); $this->assertEquals(2, count($stackTraces)); // #################################################### STACK TRACE 1 $stackTrace = array_shift($stackTraces); $this->assertEquals('0e5c398d20010437c8a7c5282269e69a', $stackTrace->getPublicId()); $data = $stackTrace->getData(); $this->assertEquals(3, count($data)); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($startNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption1->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($leftNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption3->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($endNode->getId(), $dataRow['node']->getId()); $this->assertNull($dataRow['nodeOption']); // #################################################### STACK TRACE 2 $stackTrace = array_shift($stackTraces); $this->assertEquals('10ff10dbc9b10356f7d53ed65b77a5e0', $stackTrace->getPublicId()); $data = $stackTrace->getData(); $this->assertEquals(3, count($data)); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($startNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption2->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($rightNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption4->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($endNode->getId(), $dataRow['node']->getId()); $this->assertNull($dataRow['nodeOption']); }
function testThreeNodesInLine() { $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); $middleNode = new Node(); $middleNode->setTreeVersion($treeVersion); $middleNode->setPublicId('middle'); $this->em->persist($middleNode); $endNode = new Node(); $endNode->setTreeVersion($treeVersion); $endNode->setPublicId('end'); $this->em->persist($endNode); $nodeOption1 = new NodeOption(); $nodeOption1->setTreeVersion($treeVersion); $nodeOption1->setNode($startNode); $nodeOption1->setDestinationNode($middleNode); $nodeOption1->setPublicId('no1'); $this->em->persist($nodeOption1); $nodeOption2 = new NodeOption(); $nodeOption2->setTreeVersion($treeVersion); $nodeOption2->setNode($middleNode); $nodeOption2->setDestinationNode($endNode); $nodeOption2->setPublicId('no2'); $this->em->persist($nodeOption2); $this->em->flush(); $tvsnRepo = $this->em->getRepository('QuestionKeyBundle:TreeVersionStartingNode'); $tvsnRepo->setAsStartingNode($startNode); $process = new GetStackTracesForNode($this->em, $endNode); $process->go(); $stackTraces = $process->getStackTraces(); $this->assertEquals(1, count($stackTraces)); $stackTrace = $stackTraces[0]; $this->assertEquals('e49c9061b266fe01007a004ff2cb7be3', $stackTrace->getPublicId()); $data = $stackTrace->getData(); $this->assertEquals(3, count($data)); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($startNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption1->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($middleNode->getId(), $dataRow['node']->getId()); $this->assertNotNull($dataRow['nodeOption']); $this->assertEquals($nodeOption2->getId(), $dataRow['nodeOption']->getId()); // DATA $dataRow = array_shift($data); $this->assertNotNull($dataRow['node']); $this->assertEquals($endNode->getId(), $dataRow['node']->getId()); $this->assertNull($dataRow['nodeOption']); }