Added tests to PagesController and removed twice call to count().

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7756 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
renan.saddam 2008-10-16 23:52:54 +00:00
parent 4311ba8000
commit 24949e30e0
3 changed files with 23 additions and 9 deletions

View file

@ -65,10 +65,10 @@ class PagesController extends AppController {
function display() { function display() {
$path = func_get_args(); $path = func_get_args();
if (!count($path)) { $count = count($path);
if (!$count) {
$this->redirect('/'); $this->redirect('/');
} }
$count = count($path);
$page = $subpage = $title = null; $page = $subpage = $title = null;
if (!empty($path[0])) { if (!empty($path[0])) {

View file

@ -65,10 +65,10 @@ class PagesController extends AppController {
function display() { function display() {
$path = func_get_args(); $path = func_get_args();
if (!count($path)) { $count = count($path);
if (!$count) {
$this->redirect('/'); $this->redirect('/');
} }
$count = count($path);
$page = $subpage = $title = null; $page = $subpage = $title = null;
if (!empty($path[0])) { if (!empty($path[0])) {

View file

@ -26,7 +26,7 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/ */
uses('controller' . DS . 'controller', 'controller' . DS . 'pages_controller'); App::import('Core', array('Controller', 'AppController', 'PagesController'));
/** /**
* Short description for class. * Short description for class.
* *
@ -35,13 +35,27 @@ uses('controller' . DS . 'controller', 'controller' . DS . 'pages_controller');
*/ */
class PagesControllerTest extends CakeTestCase { class PagesControllerTest extends CakeTestCase {
/** /**
* skip method * testDisplay method
* *
* @access public * @access public
* @return void * @return void
*/ */
function skip() { function testDisplay() {
$this->skipif (true, 'PagesControllerTest not implemented'); Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS));
$Pages =& new PagesController();
$Pages->viewPath = 'posts';
$Pages->display('index');
$this->assertPattern('/posts index/', $Pages->output);
$this->assertEqual($Pages->viewVars['page'], 'index');
$this->assertEqual($Pages->pageTitle, 'Index');
$Pages->viewPath = 'themed';
$Pages->display('test_theme', 'posts', 'index');
$this->assertPattern('/posts index themed view/', $Pages->output);
$this->assertEqual($Pages->viewVars['page'], 'test_theme');
$this->assertEqual($Pages->viewVars['subpage'], 'posts');
$this->assertEqual($Pages->pageTitle, 'Index');
} }
} }
?> ?>