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
|
|
|
*
|
2010-10-03 12:31:21 -04:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2012-04-26 19:49:18 -07:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
2013-02-08 20:59:49 +09:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 12:31:21 -04:00
|
|
|
* Licensed under The MIT License
|
2013-02-08 21:22:51 +09:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2010-10-03 12:31:21 -04:00
|
|
|
* Redistributions of files must retain the above copyright notice
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2013-02-08 20:59:49 +09:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2012-04-26 19:49:18 -07:00
|
|
|
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.Test.Case.Controller
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.5436
|
2013-05-31 00:11:14 +02:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-12-18 00:04:44 -04:30
|
|
|
|
2010-12-09 01:25:24 -04:30
|
|
|
App::uses('PagesController', 'Controller');
|
2009-07-24 21:18:37 +02: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
|
|
|
*
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.Test.Case.Controller
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class PagesControllerTest extends CakeTestCase {
|
2009-07-24 21:18:37 +02: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
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 22:02:32 +02:00
|
|
|
public function testDisplay() {
|
2010-01-13 23:35:56 -05:00
|
|
|
App::build(array(
|
2011-03-22 00:46:51 -04:30
|
|
|
'View' => array(
|
2012-03-11 22:20:25 -04:00
|
|
|
CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
|
2011-03-22 00:46:51 -04:30
|
|
|
)
|
2010-01-13 23:35:56 -05:00
|
|
|
));
|
2011-07-03 15:02:46 -04:00
|
|
|
$Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
|
2008-10-16 23:52:54 +00:00
|
|
|
|
2011-05-16 23:38:28 +02:00
|
|
|
$Pages->viewPath = 'Posts';
|
2008-10-16 23:52:54 +00:00
|
|
|
$Pages->display('index');
|
2011-11-15 16:07:56 -08:00
|
|
|
$this->assertRegExp('/posts index/', $Pages->response->body());
|
2012-03-22 23:37:12 -07:00
|
|
|
$this->assertEquals('index', $Pages->viewVars['page']);
|
2008-10-16 23:52:54 +00:00
|
|
|
|
2011-05-15 00:14:41 -04:30
|
|
|
$Pages->viewPath = 'Themed';
|
|
|
|
$Pages->display('TestTheme', 'Posts', 'index');
|
2011-11-15 16:07:56 -08:00
|
|
|
$this->assertRegExp('/posts index themed view/', $Pages->response->body());
|
2012-03-22 23:37:12 -07:00
|
|
|
$this->assertEquals('TestTheme', $Pages->viewVars['page']);
|
|
|
|
$this->assertEquals('Posts', $Pages->viewVars['subpage']);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2013-04-21 23:29:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that missing view renders 404 page in production
|
|
|
|
*
|
|
|
|
* @expectedException NotFoundException
|
|
|
|
* @expectedExceptionCode 404
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testMissingView() {
|
|
|
|
Configure::write('debug', 0);
|
|
|
|
$Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
|
|
|
|
$Pages->display('non_existing_page');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that missing view in debug mode renders missing_view error page
|
|
|
|
*
|
|
|
|
* @expectedException MissingViewException
|
|
|
|
* @expectedExceptionCode 500
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testMissingViewInDebug() {
|
|
|
|
Configure::write('debug', 1);
|
|
|
|
$Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
|
|
|
|
$Pages->display('non_existing_page');
|
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|