/**
  * @covers ::getTree
  */
 public function testGetTree()
 {
     $linksAcc = new \TMT\accessor\Links();
     $links = $linksAcc->getTree(1);
     $link1 = new \TMT\model\Link((object) array("name" => "link1", "resource" => null, "verb" => null, "newTab" => true, "url" => null, "children" => array()));
     $link2 = new \TMT\model\Link((object) array("name" => "link2", "resource" => null, "verb" => null, "newTab" => false, "url" => null, "children" => array(new \TMT\model\Link((object) array("name" => "child1", "resource" => null, "verb" => null, "newTab" => false, "url" => "/test", "children" => array())), new \TMT\model\Link((object) array("name" => "child2", "resource" => null, "verb" => null, "newTab" => false, "url" => null, "children" => array(new \TMT\model\Link((object) array("name" => "grandchild1", "resource" => null, "verb" => null, "newTab" => false, "url" => "url/path", "children" => array())), new \TMT\model\Link((object) array("name" => "grandchild2", "resource" => null, "verb" => null, "newTab" => false, "url" => null, "children" => array()))))), new \TMT\model\Link((object) array("name" => "child3", "resource" => null, "verb" => null, "newTab" => false, "url" => null, "children" => array())))));
     $this->assertEquals($link1, $links[0]);
     $this->assertEquals($link2, $links[1]);
 }
 /**
  * Render view
  *
  * @param $view string The name of the view
  * @param $data array  The data to use in rendering in the view
  */
 public function render($view, $data = array())
 {
     // Retrieve data necessary for properly rendering header and footer, and
     //   add that data to the template data
     $areaAcc = new \TMT\accessor\AreaAccessor();
     $employeeAcc = new \TMT\accessor\Employee();
     $linkAcc = new \TMT\accessor\Links();
     // Determine if user is admin or superuser
     $admin = $this->isAdmin();
     $su = $this->isSuperuser();
     // Get user and area information
     $user = $employeeAcc->get($this->user['netId']);
     $areaArray = $areaAcc->getAll($this->user['netId']);
     $areas = array();
     if (isset($this->user['area'])) {
         foreach ($areaArray as $area) {
             $areas[] = array('id' => $area->ID, 'name' => $area->longName);
         }
         // Retrieve link tree
         $links = $linkAcc->getTree($this->user['area']);
         $this->cleanLinkTree($links, $admin, $su);
     }
     // Check environment
     $environment = $this->getEnvironment();
     // Get quicklinks
     $quicklinks = $this->getAccessor("Quicklinks")->getByUser($this->user['netId']);
     $notificationsUrl = getenv("NOTIFICATIONSURL");
     // Add data necessary for the main header and footer to load properly
     $data['templateData'] = array("area" => isset($this->user['area']) ? $this->user['area'] : null, "areaName" => isset($this->user['area']) ? $areaAcc->get($this->user['area'])->longName : null, "areaGuid" => isset($this->user['areaGuid']) ? $this->user['areaGuid'] : null, "areas" => $areas, "authenticated" => $this->authenticated, "canSU" => $this->canBeSuperuser(), "environment" => $environment, "firstName" => $user->firstName, "isSU" => $su, "jwt" => $this->createJWT(), "lastName" => $user->lastName, "links" => isset($links) ? $links : null, "netId" => $this->user['netId'], "notificationsUrl" => $notificationsUrl, "quicklinks" => $quicklinks, "server" => $_SERVER['SERVER_NAME']);
     // load twig
     $twigLoader = new \Twig_Loader_Filesystem(self::VIEWS_PATH);
     $twig = new \Twig_Environment($twigLoader);
     // to avoid conflicts with angularjs use of {{ }}
     $lexer = new \Twig_Lexer($twig, array('tag_comment' => array('[#', '#]'), 'tag_block' => array('[%', '%]'), 'tag_variable' => array('[[', ']]'), 'interpolation' => array('#[', ']')));
     $twig->setLexer($lexer);
     // render a view
     echo $twig->render($view . self::VIEW_FILE_TYPE, $data);
 }