public function isNodeOptionAlreadyKnown(NodeOption $nodeOption)
 {
     foreach ($this->data as $data) {
         if ($data['nodeOption'] && $data['nodeOption']->getId() == $nodeOption->getId()) {
             return true;
         }
     }
     return false;
 }
 public function doesPublicIdExist($id, NodeOption $nodeOption)
 {
     if ($nodeOption->getId()) {
         $tvs = $this->getEntityManager()->createQuery(' SELECT nova FROM QuestionKeyBundle:NodeOptionVariableAction nova' . ' WHERE nova.nodeOption = :nodeOption AND nova.publicId = :public_id')->setParameter('nodeOption', $nodeOption)->setParameter('public_id', $id)->getResult();
         return (bool) $tvs;
     } else {
         return false;
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('title', 'text', array('required' => true, 'label' => 'Title'));
     $builder->add('body_text', 'textarea', array('required' => false, 'label' => 'Body (Text)'));
     $builder->add('body_html', 'textarea', array('required' => false, 'label' => 'Body (HTML)'));
     $builder->add('sort', 'text', array('required' => true, 'label' => 'Sort'));
     $this->nodeOption = $builder->getData();
     $builder->add('destination_node', 'entity', array('required' => true, 'label' => 'Destination Node', 'class' => 'QuestionKeyBundle:Node', 'expanded' => true, 'multiple' => false, 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('u')->where('u.treeVersion = :tree_version')->setParameter('tree_version', $this->nodeOption->getNode()->getTreeVersion())->orderBy('u.title', 'ASC');
     }));
 }
 function test1()
 {
     $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->setTitle("START HERE");
     $startNode->setPublicId('start');
     $this->em->persist($startNode);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setTitle("END HERE");
     $endNode->setPublicId('end');
     $this->em->persist($endNode);
     $nodeOption = new NodeOption();
     $nodeOption->setTitle("LETS GO HERE");
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($startNode);
     $nodeOption->setDestinationNode($endNode);
     $nodeOption->setPublicId('option');
     $this->em->persist($nodeOption);
     $treeVersionPublished = new TreeVersionPublished();
     $treeVersionPublished->setTreeVersion($treeVersion);
     $treeVersionPublished->setPublishedBy($user);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $published = new TreeVersionPublished();
     $published->setTreeVersion($treeVersion);
     $this->em->persist($published);
     $this->em->flush();
     // ######################################################## LOAD PAGE
     $this->driver->get('http://localhost/app_dev.php/tree/tree/demo/cascade');
     $startLink = $this->driver->findElement(WebDriverBy::id('StartTreeLink'));
     $this->assertEquals('Start Tree!', $startLink->getText());
     // ######################################################## Start Tree
     $startLink->click();
     sleep($this->sleepOnActionWithNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'));
     $this->assertEquals(0, strpos($nodeTitle->getText(), 'START HERE'));
     // ######################################################## LOAD PAGE
     $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::cssSelector('option[value="option"]'))->click();
     sleep($this->sleepOnActionNoNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'));
     $this->assertGreaterThan(0, strpos($nodeTitle->getText(), 'END HERE'));
 }
 public function process()
 {
     $nodes = array();
     foreach ($this->data->nodes as $publicId => $nodeData) {
         $nodes[$publicId] = new Node();
         $nodes[$publicId]->setPublicId($publicId);
         $nodes[$publicId]->setTreeVersion($this->treeVersion);
         $nodes[$publicId]->setTitle($nodeData->title);
         $nodes[$publicId]->setTitleAdmin($nodeData->title_admin);
         $nodes[$publicId]->setTitlePreviousAnswers($nodeData->title_previous_answers);
         $nodes[$publicId]->setBodyHTML($nodeData->body_html);
         $nodes[$publicId]->setBodyText($nodeData->body_text);
         $this->doctrine->persist($nodes[$publicId]);
     }
     foreach ($this->data->nodeOptions as $publicId => $nodeOptionData) {
         $nodeOption = new NodeOption();
         $nodeOption->setPublicId($publicId);
         $nodeOption->setTreeVersion($this->treeVersion);
         $nodeOption->setTitle($nodeOptionData->title);
         $nodeOption->setBodyHTML($nodeOptionData->body_html);
         $nodeOption->setBodyText($nodeOptionData->body_text);
         $nodeOption->setSort($nodeOptionData->sort);
         $nodeOption->setNode($nodes[$nodeOptionData->node->id]);
         $nodeOption->setDestinationNode($nodes[$nodeOptionData->destination_node->id]);
         $this->doctrine->persist($nodeOption);
     }
     // If this is removed the tests will pass ... but the web app will crash.
     $this->doctrine->flush();
     if ($this->data->start_node && $this->data->start_node->id) {
         $startingNode = new TreeVersionStartingNode();
         $startingNode->setTreeVersion($this->treeVersion);
         $startingNode->setNode($nodes[$this->data->start_node->id]);
         $this->doctrine->persist($startingNode);
     }
     // Seeing as we have to flush in this function, also flush at end to make sure all written.
     $this->doctrine->flush();
 }
Ejemplo n.º 6
0
 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));
 }
Ejemplo n.º 7
0
 /**
  *    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']);
 }
Ejemplo n.º 8
0
 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']);
 }
 /**
  *    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']);
 }
Ejemplo n.º 10
0
 function testGoBackByClickingReset()
 {
     $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->setTitle("START HERE");
     $startNode->setPublicId('start');
     $this->em->persist($startNode);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setTitle("END HERE");
     $endNode->setPublicId('end');
     $this->em->persist($endNode);
     $nodeOption = new NodeOption();
     $nodeOption->setTitle("LETS GO HERE");
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($startNode);
     $nodeOption->setDestinationNode($endNode);
     $nodeOption->setPublicId('option');
     $this->em->persist($nodeOption);
     $treeVersionPublished = new TreeVersionPublished();
     $treeVersionPublished->setTreeVersion($treeVersion);
     $treeVersionPublished->setPublishedBy($user);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $published = new TreeVersionPublished();
     $published->setTreeVersion($treeVersion);
     $this->em->persist($published);
     $this->em->flush();
     // ######################################################## LOAD PAGE
     $this->driver->get('http://localhost/app_dev.php/tree/tree/demo');
     $startLink = $this->driver->findElement(WebDriverBy::id('StartTreeLink'));
     $this->assertEquals('Start Tree!', $startLink->getText());
     // ######################################################## Start Tree
     $startLink->click();
     sleep($this->sleepOnActionWithNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('START HERE', $nodeTitle->getText());
     // ######################################################## LOAD PAGE
     $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElements(WebDriverBy::className('option'))[0]->click();
     $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::cssSelector('input[type="submit"]'))->click();
     sleep($this->sleepOnActionNoNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('END HERE', $nodeTitle->getText());
     // ######################################################## GO BACK
     $this->driver->findElement(WebDriverBy::className('restart'))->findElement(WebDriverBy::tagName('a'))->click();
     sleep($this->sleepOnActionNoNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('START HERE', $nodeTitle->getText());
 }
 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 setUp()
 {
     parent::setUp();
     // ################################################ Basic Details
     $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');
     $treeVersion->setFeatureLibraryContent(true);
     $treeVersion->setFeatureVariables(true);
     $this->em->persist($treeVersion);
     // ################################################ Variable
     $variable = new Variable();
     $variable->setTreeVersion($treeVersion);
     $variable->setName('score');
     $variable->setType('Integer');
     $this->em->persist($variable);
     // ################################################ Nodes
     $startNode = new Node();
     $startNode->setTreeVersion($treeVersion);
     $startNode->setTitle("START HERE");
     $startNode->setPublicId('start');
     $this->em->persist($startNode);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setTitle("END HERE");
     $endNode->setPublicId('end');
     $this->em->persist($endNode);
     // ################################################ Node option for points with variable action
     $nodeOptionPoints = new NodeOption();
     $nodeOptionPoints->setTitle("POINTS");
     $nodeOptionPoints->setTreeVersion($treeVersion);
     $nodeOptionPoints->setNode($startNode);
     $nodeOptionPoints->setDestinationNode($endNode);
     $nodeOptionPoints->setSort(10);
     $nodeOptionPoints->setPublicId('points');
     $this->em->persist($nodeOptionPoints);
     $nodeOptionPointsAction = new NodeOptionVariableAction();
     $nodeOptionPointsAction->setNodeOption($nodeOptionPoints);
     $nodeOptionPointsAction->setVariable($variable);
     $nodeOptionPointsAction->setValue(10);
     $nodeOptionPointsAction->setAction('assign');
     $this->em->persist($nodeOptionPointsAction);
     // ################################################ Node option for no points
     $nodeOptionNoPoints = new NodeOption();
     $nodeOptionNoPoints->setTitle("NO POINTS");
     $nodeOptionNoPoints->setTreeVersion($treeVersion);
     $nodeOptionNoPoints->setNode($startNode);
     $nodeOptionNoPoints->setDestinationNode($endNode);
     $nodeOptionNoPoints->setPublicId('nopoints');
     $nodeOptionNoPoints->setSort(100);
     $this->em->persist($nodeOptionNoPoints);
     // ################################################ Library Content for points
     $libraryContentPoints = new LibraryContent();
     $libraryContentPoints->setTreeVersion($treeVersion);
     $libraryContentPoints->setBodyText('POINTS');
     $this->em->persist($libraryContentPoints);
     $nodeHasLibraryContentPoints = new NodeHasLibraryContent();
     $nodeHasLibraryContentPoints->setSort(0);
     $nodeHasLibraryContentPoints->setNode($endNode);
     $nodeHasLibraryContentPoints->setLibraryContent($libraryContentPoints);
     $this->em->persist($nodeHasLibraryContentPoints);
     $nodeHasLibraryContentPointsIfVariable = new NodeHasLibraryContentIfVariable();
     $nodeHasLibraryContentPointsIfVariable->setPublicId('points');
     $nodeHasLibraryContentPointsIfVariable->setLibraryContent($libraryContentPoints);
     $nodeHasLibraryContentPointsIfVariable->setNode($endNode);
     $nodeHasLibraryContentPointsIfVariable->setVariable($variable);
     $nodeHasLibraryContentPointsIfVariable->setAction('>');
     $nodeHasLibraryContentPointsIfVariable->setValue(0);
     $this->em->persist($nodeHasLibraryContentPointsIfVariable);
     // ################################################ Library Content for NO points
     $libraryContentNoPoints = new LibraryContent();
     $libraryContentNoPoints->setTreeVersion($treeVersion);
     $libraryContentNoPoints->setBodyText('NO POINTS');
     $this->em->persist($libraryContentNoPoints);
     $nodeHasLibraryContentNoPoints = new NodeHasLibraryContent();
     $nodeHasLibraryContentNoPoints->setSort(0);
     $nodeHasLibraryContentNoPoints->setNode($endNode);
     $nodeHasLibraryContentNoPoints->setLibraryContent($libraryContentNoPoints);
     $this->em->persist($nodeHasLibraryContentNoPoints);
     $nodeHasLibraryContentNoPointsIfVariable = new NodeHasLibraryContentIfVariable();
     $nodeHasLibraryContentNoPointsIfVariable->setPublicId('nopoints');
     $nodeHasLibraryContentNoPointsIfVariable->setLibraryContent($libraryContentNoPoints);
     $nodeHasLibraryContentNoPointsIfVariable->setNode($endNode);
     $nodeHasLibraryContentNoPointsIfVariable->setVariable($variable);
     $nodeHasLibraryContentNoPointsIfVariable->setAction('==');
     $nodeHasLibraryContentNoPointsIfVariable->setValue(0);
     $this->em->persist($nodeHasLibraryContentNoPointsIfVariable);
     // ################################################ MISC
     $treeVersionPublished = new TreeVersionPublished();
     $treeVersionPublished->setTreeVersion($treeVersion);
     $treeVersionPublished->setPublishedBy($user);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $published = new TreeVersionPublished();
     $published->setTreeVersion($treeVersion);
     $this->em->persist($published);
     $this->em->flush();
 }
 function testGetNextSortValueForNode1()
 {
     $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);
     $node = new Node();
     $node->setTreeVersion($treeVersion);
     $node->setPublicId('start');
     $this->em->persist($node);
     $this->em->flush();
     // #################################################### TEST NO NODES
     $nodeOptionRepo = $this->em->getRepository('QuestionKeyBundle:NodeOption');
     $nextSort = $nodeOptionRepo->getNextSortValueForNode($node);
     $this->assertEquals(10, $nextSort);
     // #################################################### Add A NodeOptionRepository
     $nodeOption = new NodeOption();
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($node);
     $nodeOption->setDestinationNode($node);
     $nodeOption->setPublicId('no1');
     $nodeOption->setSort($nextSort);
     $this->em->persist($nodeOption);
     $this->em->flush();
     // #################################################### TEST NO NODES
     $nodeOptionRepo = $this->em->getRepository('QuestionKeyBundle:NodeOption');
     $nextSort = $nodeOptionRepo->getNextSortValueForNode($node);
     $this->assertEquals(20, $nextSort);
     // #################################################### Add A NodeOptionRepository
     $nodeOption = new NodeOption();
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($node);
     $nodeOption->setDestinationNode($node);
     $nodeOption->setPublicId('no2');
     $nodeOption->setSort($nextSort);
     $this->em->persist($nodeOption);
     $this->em->flush();
     // #################################################### TEST NO NODES
     $nodeOptionRepo = $this->em->getRepository('QuestionKeyBundle:NodeOption');
     $nextSort = $nodeOptionRepo->getNextSortValueForNode($node);
     $this->assertEquals(30, $nextSort);
     // #################################################### Add A NodeOptionRepository
     $nodeOption = new NodeOption();
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($node);
     $nodeOption->setDestinationNode($node);
     $nodeOption->setPublicId('no3');
     $nodeOption->setSort($nextSort);
     $this->em->persist($nodeOption);
     $this->em->flush();
     // #################################################### TEST NO NODES
     $nodeOptionRepo = $this->em->getRepository('QuestionKeyBundle:NodeOption');
     $nextSort = $nodeOptionRepo->getNextSortValueForNode($node);
     $this->assertEquals(40, $nextSort);
     // #################################################### Add A NodeOptionRepository
     $nodeOption = new NodeOption();
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($node);
     $nodeOption->setDestinationNode($node);
     $nodeOption->setPublicId('no4');
     $nodeOption->setSort($nextSort);
     $this->em->persist($nodeOption);
     $this->em->flush();
 }
 public function go()
 {
     // Tree Option
     $this->newVersion->setFromOldVersion($this->oldVersion);
     // As we call flush in this function, make sure new version will definetly be part of that.
     $this->doctrine->persist($this->newVersion);
     // repos
     $nodeRepo = $this->doctrine->getRepository('QuestionKeyBundle:Node');
     $nodeOptionRepo = $this->doctrine->getRepository('QuestionKeyBundle:NodeOption');
     $libraryContentRepo = $this->doctrine->getRepository('QuestionKeyBundle:LibraryContent');
     $nodeHasLibraryContentRepo = $this->doctrine->getRepository('QuestionKeyBundle:NodeHasLibraryContent');
     $treeStartingNodeRepo = $this->doctrine->getRepository('QuestionKeyBundle:TreeVersionStartingNode');
     // Library Content
     $libraryContents = array();
     foreach ($libraryContentRepo->findByTreeVersion($this->oldVersion) as $libraryContent) {
         $libraryContents[$libraryContent->getPublicId()] = new LibraryContent();
         $libraryContents[$libraryContent->getPublicId()]->setTitleAdmin($libraryContent->getTitleAdmin());
         $libraryContents[$libraryContent->getPublicId()]->setBodyHTML($libraryContent->getBodyHTML());
         $libraryContents[$libraryContent->getPublicId()]->setBodyText($libraryContent->getBodyText());
         $libraryContents[$libraryContent->getPublicId()]->setTreeVersion($this->newVersion);
         $libraryContents[$libraryContent->getPublicId()]->setPublicId($libraryContent->getPublicId());
         $this->doctrine->persist($libraryContents[$libraryContent->getPublicId()]);
     }
     // Nodes
     $nodes = $nodeRepo->findByTreeVersion($this->oldVersion);
     $newNodes = array();
     foreach ($nodes as $node) {
         $newNodes[$node->getId()] = new Node();
         $newNodes[$node->getId()]->setTreeVersion($this->newVersion);
         $newNodes[$node->getId()]->setTitle($node->getTitle());
         $newNodes[$node->getId()]->setBodyText($node->getBodyText());
         $newNodes[$node->getId()]->setBodyHTML($node->getBodyHTML());
         $newNodes[$node->getId()]->setPublicId($node->getPublicId());
         $newNodes[$node->getId()]->setFromOldVersion($node);
         $this->doctrine->persist($newNodes[$node->getId()]);
         $sort = 0;
         foreach ($libraryContentRepo->findForNode($node) as $oldLibraryContent) {
             // We create a NodeHasLibraryContent record directly instead of using
             //     $nodeHasLibraryContentRepo->addLibraryContentToNode($libraryContents[$oldLibraryContent->getPublicId()],  $newNodes[$node->getId()]);
             // because it's much more efficient in DB queries. Also, given some records might not have saved I'm not sure addLibraryContentToNode() would find the correct sort values anyway.
             $nodeHasLibraryContent = new NodeHasLibraryContent();
             $nodeHasLibraryContent->setLibraryContent($libraryContents[$oldLibraryContent->getPublicId()]);
             $nodeHasLibraryContent->setNode($newNodes[$node->getId()]);
             $nodeHasLibraryContent->setSort($sort++);
             $this->doctrine->persist($nodeHasLibraryContent);
         }
     }
     // Node Options
     $nodeOptions = $nodeOptionRepo->findAllNodeOptionsForTreeVersion($this->oldVersion);
     foreach ($nodeOptions as $nodeOption) {
         $newNodeOption = new NodeOption();
         $newNodeOption->setTreeVersion($this->newVersion);
         $newNodeOption->setNode($newNodes[$nodeOption->getNode()->getId()]);
         $newNodeOption->setDestinationNode($newNodes[$nodeOption->getDestinationNode()->getId()]);
         $newNodeOption->setTitle($nodeOption->getTitle());
         $newNodeOption->setBodyHTML($nodeOption->getBodyHTML());
         $newNodeOption->setBodyText($nodeOption->getBodyText());
         $newNodeOption->setSort($nodeOption->getSort());
         $newNodeOption->setPublicId($nodeOption->getPublicId());
         $newNodeOption->setFromOldVersion($nodeOption);
         $this->doctrine->persist($newNodeOption);
     }
     // Tree Start
     $treeStartingNode = $treeStartingNodeRepo->findOneByTreeVersion($this->oldVersion);
     if ($treeStartingNode) {
         // we have to flush at this point otherwise when we try and persist at the next stage you get an error.
         $this->doctrine->flush();
         $newTreeVersionStartingNode = new TreeVersionStartingNode();
         $newTreeVersionStartingNode->setTreeVersion($this->newVersion);
         $newTreeVersionStartingNode->setNode($newNodes[$treeStartingNode->getNode()->getId()]);
         $this->doctrine->persist($newTreeVersionStartingNode);
     }
     // final flush
     $this->doctrine->flush();
 }
 public function newOptionAction($treeId, $versionId, $nodeId)
 {
     // build
     $return = $this->build($treeId, $versionId, $nodeId);
     if (!$this->treeVersionEditable) {
         throw new AccessDeniedException();
     }
     //data
     $doctrine = $this->getDoctrine()->getManager();
     $nodeOptionRepo = $doctrine->getRepository('QuestionKeyBundle:NodeOption');
     $form = $this->createForm(new AdminNodeOptionNewType($this->node, $nodeOptionRepo->getNextSortValueForNode($this->node)));
     $request = $this->getRequest();
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $nodeOption = new NodeOption();
             $nodeOption->setTreeVersion($this->treeVersion);
             $nodeOption->setNode($this->node);
             $nodeOption->setTitle($form->get('title')->getData());
             $nodeOption->setBodyText($form->get('body_text')->getData());
             $nodeOption->setBodyHTML($form->get('body_html')->getData());
             $nodeOption->setSort($form->get('sort')->getData());
             $nodeOption->setDestinationNode($form->get('destination_node')->getData());
             $doctrine->persist($nodeOption);
             $doctrine->flush();
             return $this->redirect($this->generateUrl('questionkey_admin_tree_version_node_show', array('treeId' => $this->tree->getPublicId(), 'versionId' => $this->treeVersion->getPublicId(), 'nodeId' => $this->node->getPublicId())));
         }
     }
     return $this->render('QuestionKeyBundle:AdminTreeVersionNodeEdit:newOption.html.twig', array('form' => $form->createView(), 'tree' => $this->tree, 'treeVersion' => $this->treeVersion, 'node' => $this->node));
 }
 function testNextNodeInExistingRun()
 {
     $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);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setPublicId('end');
     $this->em->persist($endNode);
     $nodeOption1 = new NodeOption();
     $nodeOption1->setTreeVersion($treeVersion);
     $nodeOption1->setNode($startNode);
     $nodeOption1->setDestinationNode($endNode);
     $nodeOption1->setPublicId('no1');
     $this->em->persist($nodeOption1);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $tp = new TreeVersionPublished();
     $tp->setTreeVersion($treeVersion);
     $tp->setPublishedBy($user);
     $tp->setPublishedAt(new \DateTime());
     $this->em->persist($tp);
     $session = new VisitorSession();
     $session->setPublicId('vspid');
     $this->em->persist($session);
     $visitorSessionRanTreeVersion = new VisitorSessionRanTreeVersion();
     $visitorSessionRanTreeVersion->setVisitorSession($session);
     $visitorSessionRanTreeVersion->setPublicId('vsrtvpid');
     $visitorSessionRanTreeVersion->setTreeVersion($treeVersion);
     $this->em->persist($visitorSessionRanTreeVersion);
     $visitorSessionOnNode = new VisitorSessionOnNode();
     $visitorSessionOnNode->setNode($startNode);
     $visitorSessionOnNode->setSessionRanTreeVersion($visitorSessionRanTreeVersion);
     $this->em->persist($visitorSessionOnNode);
     $this->em->flush();
     // Make Request
     $client = static::createClient();
     $crawler = $client->request('GET', '/api/v1/visitorsession/action.json?session_id=vspid&ran_tree_version_id=vsrtvpid&tree_id=tree&tree_version_id=version&node_id=end&node_option_id=no1');
     $response = $client->getResponse()->getContent();
     $responseData = json_decode($response);
     // Check Session
     $sessionLoaded = $this->em->getRepository('QuestionKeyBundle:VisitorSession')->findOneByPublicId($responseData->session->id);
     $this->assertNotNull($sessionLoaded);
     $this->assertEquals($responseData->session->id, $sessionLoaded->getPublicId());
     // test session we loaded is same as session we passed it get param
     $this->assertEquals($session->getId(), $sessionLoaded->getId());
     // Check Session Ran Tree
     $sessionRanTreeLoaded = $this->em->getRepository('QuestionKeyBundle:VisitorSessionRanTreeVersion')->findOneByPublicId($responseData->session_ran_tree_version->id);
     $this->assertNotNull($sessionRanTreeLoaded);
     $this->assertEquals($responseData->session_ran_tree_version->id, $sessionRanTreeLoaded->getPublicId());
     $this->assertEquals($sessionLoaded->getId(), $sessionRanTreeLoaded->getVisitorSession()->getId());
     $this->assertEquals($treeVersion->getId(), $sessionRanTreeLoaded->getTreeVersion()->getId());
     // test s-r-t we loaded is same as s-r-t we passed it get param
     $this->assertEquals($visitorSessionRanTreeVersion->getId(), $sessionRanTreeLoaded->getId());
     // Check Node Stored.
     $sessionOnNodesLoaded = $this->em->getRepository('QuestionKeyBundle:VisitorSessionOnNode')->findBy(array('sessionRanTreeVersion' => $sessionRanTreeLoaded));
     $this->assertEquals(2, count($sessionOnNodesLoaded));
     $sessionOnNodeLoaded = array_shift($sessionOnNodesLoaded);
     $this->assertEquals($startNode->getId(), $sessionOnNodeLoaded->getNode()->getId());
     $this->assertFalse($sessionOnNodeLoaded->getGoneBackTo());
     $this->assertNull($sessionOnNodeLoaded->getNodeOption());
     $sessionOnNodeLoaded = array_shift($sessionOnNodesLoaded);
     $this->assertEquals($endNode->getId(), $sessionOnNodeLoaded->getNode()->getId());
     $this->assertFalse($sessionOnNodeLoaded->getGoneBackTo());
     $this->assertNotNull($sessionOnNodeLoaded->getNodeOption());
     $this->assertEquals($nodeOption1->getId(), $sessionOnNodeLoaded->getNodeOption()->getId());
 }
 function test1()
 {
     $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');
     $startNode->setTitle('Start Here');
     $this->em->persist($startNode);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setPublicId('end');
     $endNode->setTitle('End Here');
     $this->em->persist($endNode);
     $nodeOption = new NodeOption();
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setTitle('Click Here');
     $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();
     ///////////////////////////////////////////////////////////////////// NOW EXPORT
     $exportJSON = new ExportTreeVersionJSON($this->em, $treeVersion);
     $json = $exportJSON->getAsText();
     ///////////////////////////////////////////////////////////////////// NOW IMPORT
     $tree = new Tree();
     $tree->setTitleAdmin('Tree IMPORTED');
     $tree->setPublicId('tree_imported');
     $tree->setOwner($user);
     $this->em->persist($tree);
     $treeVersion = new TreeVersion();
     $treeVersion->setTree($tree);
     $treeVersion->setPublicId('version');
     $this->em->persist($treeVersion);
     $this->em->flush();
     $importJSON = new ImportTreeVersionJSON($this->em, $treeVersion, $json);
     $this->assertTrue($importJSON->hasData());
     $importJSON->process();
     $this->em->flush();
     ///////////////////////////////////////////////////////////////////// TEST IMPORTED TREE
     $nodeRepo = $this->em->getRepository('QuestionKeyBundle:Node');
     $startNode = $nodeRepo->findOneBy(array('treeVersion' => $treeVersion, 'publicId' => 'start'));
     $this->assertNotNull($startNode);
     $this->assertEquals('Start Here', $startNode->getTitle());
     $endNode = $nodeRepo->findOneBy(array('treeVersion' => $treeVersion, 'publicId' => 'end'));
     $this->assertNotNull($endNode);
     $this->assertEquals('End Here', $endNode->getTitle());
     $nodeOptionRepo = $this->em->getRepository('QuestionKeyBundle:NodeOption');
     $nodeOption = $nodeOptionRepo->findOneBy(array('treeVersion' => $treeVersion, 'publicId' => 'option'));
     $this->assertNotNull($nodeOption);
     $this->assertEquals('Click Here', $nodeOption->getTitle());
     $this->assertEquals('start', $nodeOption->getNode()->getPublicId());
     $this->assertEquals('end', $nodeOption->getDestinationNode()->getPublicId());
     $tvsnRepo = $this->em->getRepository('QuestionKeyBundle:TreeVersionStartingNode');
     $tvsn = $tvsnRepo->findOneBy(array('treeVersion' => $treeVersion));
     $this->assertNotNull($tvsn);
     $this->assertEquals('start', $tvsn->getNode()->getPublicId());
 }