Skip to content

Commit

Permalink
Added a ignoreCase flag to the assertResponseContains test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
viraj-khatavkar committed Jul 19, 2017
1 parent 648179d commit 4395856
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/TestSuite/IntegrationTestCase.php
Expand Up @@ -913,14 +913,15 @@ public function assertResponseEquals($content, $message = '')
*
* @param string $content The content to check for.
* @param string $message The failure message that will be appended to the generated message.
* @param bool $ignoreCase A flag to check whether we should ignore case or not.
* @return void
*/
public function assertResponseContains($content, $message = '')
public function assertResponseContains($content, $ignoreCase = false, $message = '')
{
if (!$this->_response) {
$this->fail('No response set, cannot assert content. ' . $message);
}
$this->assertContains($content, $this->_getBodyAsString(), $message);
$this->assertContains($content, $this->_getBodyAsString(), $message, $ignoreCase);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions tests/TestCase/TestSuite/IntegrationTestCaseTest.php
Expand Up @@ -827,6 +827,19 @@ public function testAssertResponseContains()
$this->assertResponseContains('content');
}

/**
* Test the content assertion with no case sensitivity.
*
* @return void
*/
public function testAssertResponseContainsWithIgnoreCaseFlag()
{
$this->_response = new Response();
$this->_response = $this->_response->withStringBody('Some content');

$this->assertResponseContains('some', true);
}

/**
* Test the negated content assertion.
*
Expand Down

0 comments on commit 4395856

Please sign in to comment.