diff --git a/src/TestSuite/IntegrationTestCase.php b/src/TestSuite/IntegrationTestCase.php index f8109a46e05..4c16fc8d43d 100644 --- a/src/TestSuite/IntegrationTestCase.php +++ b/src/TestSuite/IntegrationTestCase.php @@ -438,4 +438,32 @@ public function assertResponseContains($content, $message = '') { $this->assertContains($content, $this->_response->body(), $message); } +/** + * Assert that the search string was in the template name. + * + * @param string $file The content to check for. + * @param string $message The failure message that will be appended to the generated message. + * @return void + */ + public function assertTemplate($content, $message = '') { + if (!$this->_viewName) { + $this->fail('No view name stored. ' . $message); + } + $this->assertContains($content, $this->_viewName, $message); + } + +/** + * Assert that the search string was in the layout name. + * + * @param string $file The content to check for. + * @param string $message The failure message that will be appended to the generated message. + * @return void + */ + public function assertLayout($content, $message = '') { + if (!$this->_layoutName) { + $this->fail('No layout name stored. ' . $message); + } + $this->assertContains($content, $this->_layoutName, $message); + } + } diff --git a/tests/TestCase/TestSuite/IntegrationTestCaseTest.php b/tests/TestCase/TestSuite/IntegrationTestCaseTest.php index 5065e86c832..e55848c1a76 100644 --- a/tests/TestCase/TestSuite/IntegrationTestCaseTest.php +++ b/tests/TestCase/TestSuite/IntegrationTestCaseTest.php @@ -85,10 +85,15 @@ public function testRequestSetsProperties() { $this->assertInstanceOf('Cake\Controller\Controller', $this->_controller); $this->assertContains('Template' . DS . 'Posts' . DS . 'index.ctp', $this->_viewName); $this->assertContains('Template' . DS . 'Layout' . DS . 'default.ctp', $this->_layoutName); + + $this->assertTemplate('index'); + $this->assertLayout('default'); } /** + * Test error handling and error page rendering. * + * @return void */ public function testPostAndErrorHandling() { $this->post('/request_action/error_method');