adding example apps, fixing powerup issues
[feisty_meow.git] / production / example_apps / zippy_maps / tests / TestCase / Controller / PagesControllerTest.php
1 <?php
2 /**
3  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
5  *
6  * Licensed under The MIT License
7  * For full copyright and license information, please see the LICENSE.txt
8  * Redistributions of files must retain the above copyright notice
9  *
10  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11  * @link          http://cakephp.org CakePHP(tm) Project
12  * @since         1.2.0
13  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
14  */
15 namespace App\Test\TestCase\Controller;
16
17 use App\Controller\PagesController;
18 use Cake\Core\App;
19 use Cake\Core\Configure;
20 use Cake\Network\Request;
21 use Cake\Network\Response;
22 use Cake\TestSuite\IntegrationTestCase;
23 use Cake\View\Exception\MissingTemplateException;
24
25 /**
26  * PagesControllerTest class
27  */
28 class PagesControllerTest extends IntegrationTestCase
29 {
30     /**
31      * testMultipleGet method
32      *
33      * @return void
34      */
35     public function testMultipleGet()
36     {
37         $this->get('/');
38         $this->assertResponseOk();
39         $this->get('/');
40         $this->assertResponseOk();
41     }
42
43     /**
44      * testDisplay method
45      *
46      * @return void
47      */
48     public function testDisplay()
49     {
50         $this->get('/pages/home');
51         $this->assertResponseOk();
52         $this->assertResponseContains('CakePHP');
53         $this->assertResponseContains('<html>');
54     }
55
56     /**
57      * Test that missing template renders 404 page in production
58      *
59      * @return void
60      */
61     public function testMissingTemplate()
62     {
63         Configure::write('debug', false);
64         $this->get('/pages/not_existing');
65
66         $this->assertResponseError();
67         $this->assertResponseContains('Error');
68     }
69
70     /**
71      * Test that missing template in debug mode renders missing_template error page
72      *
73      * @return void
74      */
75     public function testMissingTemplateInDebug()
76     {
77         Configure::write('debug', true);
78         $this->get('/pages/not_existing');
79
80         $this->assertResponseFailure();
81         $this->assertResponseContains('Missing Template');
82         $this->assertResponseContains('Stacktrace');
83         $this->assertResponseContains('not_existing.ctp');
84     }
85
86     /**
87      * Test directory traversal protection
88      *
89      * @return void
90      */
91     public function testDirectoryTraversalProtection()
92     {
93         $this->get('/pages/../Layout/ajax');
94         $this->assertResponseCode(403);
95         $this->assertResponseContains('Forbidden');
96     }
97 }