pictcode / lib / Cake / Test / Case / Controller / PagesControllerTest.php @ 9d2f0219
履歴 | 表示 | アノテート | ダウンロード (2.32 KB)
| 1 | 635eef61 | spyder1211 | <?php
|
|---|---|---|---|
| 2 | /**
|
||
| 3 | * PagesControllerTest file
|
||
| 4 | *
|
||
| 5 | * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||
| 6 | * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
| 7 | *
|
||
| 8 | * Licensed under The MIT License
|
||
| 9 | * For full copyright and license information, please see the LICENSE.txt
|
||
| 10 | * Redistributions of files must retain the above copyright notice
|
||
| 11 | *
|
||
| 12 | * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
| 13 | * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
||
| 14 | * @package Cake.Test.Case.Controller
|
||
| 15 | * @since CakePHP(tm) v 1.2.0.5436
|
||
| 16 | * @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||
| 17 | */
|
||
| 18 | |||
| 19 | App::uses('PagesController', 'Controller'); |
||
| 20 | |||
| 21 | /**
|
||
| 22 | * PagesControllerTest class
|
||
| 23 | *
|
||
| 24 | * @package Cake.Test.Case.Controller
|
||
| 25 | */
|
||
| 26 | class PagesControllerTest extends CakeTestCase { |
||
| 27 | |||
| 28 | /**
|
||
| 29 | * testDisplay method
|
||
| 30 | *
|
||
| 31 | * @return void
|
||
| 32 | */
|
||
| 33 | public function testDisplay() { |
||
| 34 | App::build(array( |
||
| 35 | 'View' => array( |
||
| 36 | CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS |
||
| 37 | ) |
||
| 38 | )); |
||
| 39 | $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); |
||
| 40 | |||
| 41 | $Pages->viewPath = 'Posts'; |
||
| 42 | $Pages->display('index'); |
||
| 43 | $this->assertRegExp('/posts index/', $Pages->response->body()); |
||
| 44 | $this->assertEquals('index', $Pages->viewVars['page']); |
||
| 45 | |||
| 46 | $Pages->viewPath = 'Themed'; |
||
| 47 | $Pages->display('TestTheme', 'Posts', 'index'); |
||
| 48 | $this->assertRegExp('/posts index themed view/', $Pages->response->body()); |
||
| 49 | $this->assertEquals('TestTheme', $Pages->viewVars['page']); |
||
| 50 | $this->assertEquals('Posts', $Pages->viewVars['subpage']); |
||
| 51 | } |
||
| 52 | |||
| 53 | /**
|
||
| 54 | * Test that missing view renders 404 page in production
|
||
| 55 | *
|
||
| 56 | * @expectedException NotFoundException
|
||
| 57 | * @expectedExceptionCode 404
|
||
| 58 | * @return void
|
||
| 59 | */
|
||
| 60 | public function testMissingView() { |
||
| 61 | Configure::write('debug', 0); |
||
| 62 | $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); |
||
| 63 | $Pages->display('non_existing_page'); |
||
| 64 | } |
||
| 65 | |||
| 66 | /**
|
||
| 67 | * Test that missing view in debug mode renders missing_view error page
|
||
| 68 | *
|
||
| 69 | * @expectedException MissingViewException
|
||
| 70 | * @expectedExceptionCode 500
|
||
| 71 | * @return void
|
||
| 72 | */
|
||
| 73 | public function testMissingViewInDebug() { |
||
| 74 | Configure::write('debug', 1); |
||
| 75 | $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); |
||
| 76 | $Pages->display('non_existing_page'); |
||
| 77 | } |
||
| 78 | } |