2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* PagesControllerTest file
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2010-05-19 01:15:13 +00:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
2010-01-26 19:18:20 +00:00
|
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2010-01-26 19:18:20 +00:00
|
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-05-19 01:15:13 +00:00
|
|
|
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs.controller
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5436
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-03-21 23:55:39 +00:00
|
|
|
if (!class_exists('AppController')) {
|
|
|
|
require_once LIBS . 'controller' . DS . 'app_controller.php';
|
|
|
|
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
|
|
|
|
define('APP_CONTROLLER_EXISTS', true);
|
|
|
|
}
|
2009-07-26 01:27:02 +00:00
|
|
|
App::import('Controller', 'Pages');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* PagesControllerTest class
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs.controller
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class PagesControllerTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-21 23:55:39 +00:00
|
|
|
/**
|
2009-06-11 16:13:16 +00:00
|
|
|
* endTest method
|
2009-03-21 23:55:39 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2009-06-11 16:13:16 +00:00
|
|
|
function endTest() {
|
|
|
|
App::build();
|
2009-03-21 23:55:39 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2008-10-16 23:52:54 +00:00
|
|
|
* testDisplay method
|
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-10-16 23:52:54 +00:00
|
|
|
function testDisplay() {
|
2009-03-21 23:55:39 +00:00
|
|
|
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-14 04:35:56 +00:00
|
|
|
App::build(array(
|
|
|
|
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)
|
|
|
|
));
|
2010-05-27 04:28:51 +00:00
|
|
|
$Pages = new PagesController(new CakeRequest(null, false));
|
2008-10-16 23:52:54 +00:00
|
|
|
|
|
|
|
$Pages->viewPath = 'posts';
|
|
|
|
$Pages->display('index');
|
2010-08-28 05:15:23 +00:00
|
|
|
$this->assertPattern('/posts index/', $Pages->getResponse()->body());
|
2008-10-16 23:52:54 +00:00
|
|
|
$this->assertEqual($Pages->viewVars['page'], 'index');
|
|
|
|
|
|
|
|
$Pages->viewPath = 'themed';
|
|
|
|
$Pages->display('test_theme', 'posts', 'index');
|
2010-08-28 05:15:23 +00:00
|
|
|
$this->assertPattern('/posts index themed view/', $Pages->getResponse()->body());
|
2008-10-16 23:52:54 +00:00
|
|
|
$this->assertEqual($Pages->viewVars['page'], 'test_theme');
|
|
|
|
$this->assertEqual($Pages->viewVars['subpage'], 'posts');
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|