Skip to content

Commit

Permalink
Refactor to use helper method + test coverage.
Browse files Browse the repository at this point in the history
Refs #9842
Refs #9847
  • Loading branch information
markstory committed Dec 8, 2016
1 parent 9b3a191 commit fc2d1f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/TestSuite/IntegrationTestCase.php
Expand Up @@ -879,7 +879,7 @@ public function assertResponseRegExp($pattern, $message = '')
if (!$this->_response) {
$this->fail('No response set, cannot assert content. ' . $message);
}
$this->assertRegExp($pattern, (string)$this->_response->body(), $message);
$this->assertRegExp($pattern, $this->_getBodyAsString(), $message);
}

/**
Expand All @@ -894,7 +894,7 @@ public function assertResponseNotRegExp($pattern, $message = '')
if (!$this->_response) {
$this->fail('No response set, cannot assert content. ' . $message);
}
$this->assertNotRegExp($pattern, (string)$this->_response->body(), $message);
$this->assertNotRegExp($pattern, $this->_getBodyAsString(), $message);
}

/**
Expand Down
24 changes: 24 additions & 0 deletions tests/TestCase/TestSuite/IntegrationTestCaseTest.php
Expand Up @@ -762,6 +762,18 @@ public function testAssertResponseRegExp()
$this->assertResponseRegExp('/cont/');
}

/**
* Test the content regexp assertion failing
*
* @expectedException \PHPUnit_Framework_AssertionFailedError
* @expectedExceptionMessage No response set
* @return void
*/
public function testAssertResponseRegExpNoResponse()
{
$this->assertResponseRegExp('/cont/');
}

/**
* Test the negated content regexp assertion.
*
Expand All @@ -775,6 +787,18 @@ public function testAssertResponseNotRegExp()
$this->assertResponseNotRegExp('/cant/');
}

/**
* Test negated content regexp assertion failing
*
* @expectedException \PHPUnit_Framework_AssertionFailedError
* @expectedExceptionMessage No response set
* @return void
*/
public function testAssertResponseNotRegExpNoResponse()
{
$this->assertResponseNotRegExp('/cont/');
}

/**
* Test that works in tandem with testEventManagerReset2 to
* test the EventManager reset.
Expand Down

0 comments on commit fc2d1f4

Please sign in to comment.