Skip to content

Commit

Permalink
Add asserts for template/layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 9, 2014
1 parent f2969a2 commit e35b808
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/TestSuite/IntegrationTestCase.php
Expand Up @@ -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);
}

}
5 changes: 5 additions & 0 deletions tests/TestCase/TestSuite/IntegrationTestCaseTest.php
Expand Up @@ -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');
Expand Down

0 comments on commit e35b808

Please sign in to comment.