diff --git a/cake/console/libs/templates/skel/controllers/pages_controller.php b/cake/console/libs/templates/skel/controllers/pages_controller.php index b1017935a..5f422a2db 100644 --- a/cake/console/libs/templates/skel/controllers/pages_controller.php +++ b/cake/console/libs/templates/skel/controllers/pages_controller.php @@ -65,10 +65,10 @@ class PagesController extends AppController { function display() { $path = func_get_args(); - if (!count($path)) { + $count = count($path); + if (!$count) { $this->redirect('/'); } - $count = count($path); $page = $subpage = $title = null; if (!empty($path[0])) { diff --git a/cake/libs/controller/pages_controller.php b/cake/libs/controller/pages_controller.php index b1017935a..5f422a2db 100644 --- a/cake/libs/controller/pages_controller.php +++ b/cake/libs/controller/pages_controller.php @@ -65,10 +65,10 @@ class PagesController extends AppController { function display() { $path = func_get_args(); - if (!count($path)) { + $count = count($path); + if (!$count) { $this->redirect('/'); } - $count = count($path); $page = $subpage = $title = null; if (!empty($path[0])) { diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index bf2eca006..8c9172c70 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -26,7 +26,7 @@ * @lastmodified $Date$ * @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. * @@ -35,13 +35,27 @@ uses('controller' . DS . 'controller', 'controller' . DS . 'pages_controller'); */ class PagesControllerTest extends CakeTestCase { /** - * skip method - * + * testDisplay method + * * @access public * @return void */ - function skip() { - $this->skipif (true, 'PagesControllerTest not implemented'); + function testDisplay() { + 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'); } } ?> \ No newline at end of file