Example #1
0
 /**
  * Test controller
  * @TODO Possibly load the resulting markup as a DOM object and test various children in it; this would enforce valid markup
  */
 function testControl()
 {
     $config = Config::getInstance();
     $controller = new TestController(true);
     $results = $controller->go();
     //test if view variables were set correctly
     $v_mgr = $controller->getViewManager();
     $this->assertEqual($v_mgr->getTemplateDataItem('test'), 'Testing, testing, 123');
     $this->assertEqual($v_mgr->getTemplateDataItem('app_title'), 'ThinkTank');
     $this->assertEqual($results, '<a href="' . $config->getValue('site_root_path') . 'index.php">ThinkTank</a>: Testing, testing, 123 | Not logged in', "controller output");
 }
 /**
  * Test exception handling
  */
 public function testExceptionHandling()
 {
     $_GET['throwexception'] = 'yesindeedy';
     $controller = new TestController(true);
     $results = $controller->go();
     $v_mgr = $controller->getViewManager();
     $config = Config::getInstance();
     $this->assertEqual('Testing exception handling!', $v_mgr->getTemplateDataItem('error_msg'));
     $this->assertPattern('/<html/', $results);
     $_GET['json'] = true;
     $results = $controller->go();
     $this->debug($results);
     $this->assertFalse(strpos($results, '<html'));
     $this->assertPattern('/{/', $results);
     $this->assertPattern('/Testing exception handling/', $results);
     $this->assertEqual('Exception', $v_mgr->getTemplateDataItem('error_type'));
     unset($_GET['json']);
     $_GET['text'] = true;
     $results = $controller->go();
     $this->assertFalse(strpos($results, '<html'));
     $this->assertFalse(strpos($results, '{'));
     $this->assertPattern('/Testing exception handling/', $results);
     $this->assertEqual('Exception', $v_mgr->getTemplateDataItem('error_type'));
     unset($_GET['text']);
 }