/** * testAltBadExt method * * @expectedException MissingViewException * @return void */ public function testAltBadExt() { $View = new TestView($this->PostsController); $View->render('alt_ext'); }
/** * 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); }
/** * 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()); }
/** * 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()); }
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); }