3 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
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
10 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11 * @link http://cakephp.org CakePHP(tm) Project
13 * @license http://www.opensource.org/licenses/mit-license.php MIT License
15 namespace App\Test\TestCase\Controller;
17 use App\Controller\PagesController;
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;
26 * PagesControllerTest class
28 class PagesControllerTest extends IntegrationTestCase
31 * testMultipleGet method
35 public function testMultipleGet()
38 $this->assertResponseOk();
40 $this->assertResponseOk();
48 public function testDisplay()
50 $this->get('/pages/home');
51 $this->assertResponseOk();
52 $this->assertResponseContains('CakePHP');
53 $this->assertResponseContains('<html>');
57 * Test that missing template renders 404 page in production
61 public function testMissingTemplate()
63 Configure::write('debug', false);
64 $this->get('/pages/not_existing');
66 $this->assertResponseError();
67 $this->assertResponseContains('Error');
71 * Test that missing template in debug mode renders missing_template error page
75 public function testMissingTemplateInDebug()
77 Configure::write('debug', true);
78 $this->get('/pages/not_existing');
80 $this->assertResponseFailure();
81 $this->assertResponseContains('Missing Template');
82 $this->assertResponseContains('Stacktrace');
83 $this->assertResponseContains('not_existing.ctp');
87 * Test directory traversal protection
91 public function testDirectoryTraversalProtection()
93 $this->get('/pages/../Layout/ajax');
94 $this->assertResponseCode(403);
95 $this->assertResponseContains('Forbidden');