get('/'); $this->assertResponseOk(); $this->get('/'); $this->assertResponseOk(); } /** * testDisplay method * * @return void */ public function testDisplay() { $this->get('/pages/home'); $this->assertResponseOk(); $this->assertResponseContains('CakePHP'); $this->assertResponseContains(''); } /** * Test that missing template renders 404 page in production * * @return void */ public function testMissingTemplate() { Configure::write('debug', false); $this->get('/pages/not_existing'); $this->assertResponseError(); $this->assertResponseContains('Error'); } /** * Test that missing template in debug mode renders missing_template error page * * @return void */ public function testMissingTemplateInDebug() { Configure::write('debug', true); $this->get('/pages/not_existing'); $this->assertResponseFailure(); $this->assertResponseContains('Missing Template'); $this->assertResponseContains('Stacktrace'); $this->assertResponseContains('not_existing.php'); } /** * Test directory traversal protection * * @return void */ public function testDirectoryTraversalProtection() { $this->get('/pages/../Layout/ajax'); $this->assertResponseCode(403); $this->assertResponseContains('Forbidden'); } /** * Test that CSRF protection is applied to page rendering. * * @reutrn void */ public function testCsrfAppliedError() { $this->post('/pages/home', ['hello' => 'world']); $this->assertResponseCode(403); $this->assertResponseContains('CSRF'); } /** * Test that CSRF protection is applied to page rendering. * * @reutrn void */ public function testCsrfAppliedOk() { $this->enableCsrfToken(); $this->post('/pages/home', ['hello' => 'world']); $this->assertResponseCode(200); $this->assertResponseContains('CakePHP'); } }