Inheritance: extends UnitTestCase
Exemple #1
0
 function getData()
 {
     $testModel = new TestModel();
     $data = $testModel->setData();
     $testView = new TestView();
     $testView->display($data);
 }
Exemple #2
0
 function getItemsAction()
 {
     $model = new TestModel();
     $data = $model->getItems();
     $view = new TestView();
     $view->renderItemsPage($data);
 }
Exemple #3
0
 function testFileOutput()
 {
     $var = "blah blah";
     $html = 'test html here <?php echo $var?>';
     $args = array("var" => $var);
     $check = "test html here {$var}";
     $view = new TestView($this->view_name, $this->view_type, $this->view_dir, $args);
     ob_start();
     $output = $view->show_view();
     $output = ob_get_clean();
     $this->assertIdentical($check, $output);
 }
Exemple #4
0
 /**
  * testAltBadExt method
  *
  * @expectedException MissingViewException
  * @return void
  */
 public function testAltBadExt()
 {
     $View = new TestView($this->PostsController);
     $View->render('alt_ext');
 }
Exemple #5
0
 /**
  * testBadExt method
  *
  * @access public
  * @return void
  */
 function testBadExt()
 {
     $this->PostsController->action = 'something';
     $this->PostsController->ext = '.whatever';
     restore_error_handler();
     ob_start();
     $View = new TestView($this->PostsController);
     $View->render('this_is_missing');
     $result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
     set_error_handler('simpleTestErrorHandler');
     $this->assertPattern("/<em>PostsController::<\\/em><em>something\\(\\)<\\/em>/", $result);
     $this->assertPattern("/posts(\\/|\\\\)this_is_missing.whatever/", $result);
     $this->PostsController->ext = ".bad";
     $View =& new TestView($this->PostsController);
     $result = str_replace(array("\t", "\r\n", "\n"), "", $View->render('index'));
     $this->assertPattern("/<meta http-equiv=\"Content-Type\" content=\"text\\/html; charset=utf-8\" \\/><title>/", $result);
     $this->assertPattern("/<div id=\"content\">posts index<\\/div>/", $result);
 }
 /**
  * testBadExt method
  *
  * @expectedException MissingViewException
  * @access public
  * @return void
  */
 function testBadExt()
 {
     $this->PostsController->action = 'something';
     $this->PostsController->ext = '.whatever';
     $View = new TestView($this->PostsController);
     $View->render('this_is_missing');
     $result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
 }
 /**
  * testAltBadExt method
  *
  * @expectedException MissingViewException
  * @return void
  */
 public function testAltBadExt()
 {
     $View = new TestView($this->PostsController);
     $View->render('alt_ext');
     $result = str_replace(array("\t", "\r\n", "\n"), "", ob_get_clean());
 }
 function testElementCache()
 {
     $View = new TestView($this->PostsController);
     $element = 'element_name';
     $result = $View->element($element);
     $this->assertEqual($result, $element);
     $cached = false;
     $result = $View->element($element, array('cache' => '+1 second'));
     if (file_exists(CACHE . 'views' . DS . 'element_cache_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_cache_' . $element);
     }
     $this->assertTrue($cached);
     $cached = false;
     $result = $View->element($element, array('cache' => '+1 second', 'other_param' => true, 'anotherParam' => true));
     if (file_exists(CACHE . 'views' . DS . 'element_cache_other_param_anotherParam_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_cache_other_param_anotherParam_' . $element);
     }
     $this->assertTrue($cached);
     $cached = false;
     $result = $View->element($element, array('cache' => array('time' => '+1 second', 'key' => '/whatever/here')));
     if (file_exists(CACHE . 'views' . DS . 'element_' . convertSlash('/whatever/here') . '_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_' . convertSlash('/whatever/here') . '_' . $element);
     }
     $this->assertTrue($cached);
     $cached = false;
     $result = $View->element($element, array('cache' => array('time' => '+1 second', 'key' => 'whatever_here')));
     if (file_exists(CACHE . 'views' . DS . 'element_whatever_here_' . $element)) {
         $cached = true;
         unlink(CACHE . 'views' . DS . 'element_whatever_here_' . $element);
     }
     $this->assertTrue($cached);
     $this->assertEqual($result, $element);
 }
Exemple #9
0
    function testRender()
    {
        $View = new TestView($this->PostsController);
        ob_start();
        $View->render('index');
        $result = ob_get_clean();
        $expected = '
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<title>
				CakePHP: the rapid development php framework:		Posts	</title>

			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<link rel="icon" href="favicon.ico" type="image/x-icon" />
			<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
			<link rel="stylesheet" type="text/css" href="css/cake.generic.css" />	</head>
		<body>
			<div id="container">
				<div id="header">
					<h1><a href="http://cakephp.org">CakePHP: the rapid development php framework</a></h1>
				</div>
				<div id="content">

					posts index
				</div>
				<div id="footer">
					<a href="http://www.cakephp.org/" target="_new"><img src="img/cake.power.gif" alt="CakePHP: the rapid development php framework" border="0" /></a>		</div>
			</div>
			</body>
		</html>
		';
        $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
        $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
        $this->assertEqual($result, $expected);
        $this->PostsController->set('url', 'flash');
        $this->PostsController->set('message', 'yo what up');
        $this->PostsController->set('pause', 3);
        $this->PostsController->set('page_title', 'yo what up');
        $View = new TestView($this->PostsController);
        ob_start();
        $View->render(false, 'flash');
        $result = ob_get_clean();
        $expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<title>yo what up</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<style><!--
		P { text-align:center; font:bold 1.1em sans-serif }
		A { color:#444; text-decoration:none }
		A:HOVER { text-decoration: underline; color:#44E }
		--></style>
		</head>
		<body>
		<p><a href="flash">yo what up</a></p>
		</body>
		</html>';
        $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
        $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
        $this->assertEqual($result, $expected);
    }