Skip to content

Commit fc2d1f4

Browse files
committed
Refactor to use helper method + test coverage.
Refs #9842 Refs #9847
1 parent 9b3a191 commit fc2d1f4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/TestSuite/IntegrationTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ public function assertResponseRegExp($pattern, $message = '')
879879
if (!$this->_response) {
880880
$this->fail('No response set, cannot assert content. ' . $message);
881881
}
882-
$this->assertRegExp($pattern, (string)$this->_response->body(), $message);
882+
$this->assertRegExp($pattern, $this->_getBodyAsString(), $message);
883883
}
884884

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

900900
/**

tests/TestCase/TestSuite/IntegrationTestCaseTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,18 @@ public function testAssertResponseRegExp()
762762
$this->assertResponseRegExp('/cont/');
763763
}
764764

765+
/**
766+
* Test the content regexp assertion failing
767+
*
768+
* @expectedException \PHPUnit_Framework_AssertionFailedError
769+
* @expectedExceptionMessage No response set
770+
* @return void
771+
*/
772+
public function testAssertResponseRegExpNoResponse()
773+
{
774+
$this->assertResponseRegExp('/cont/');
775+
}
776+
765777
/**
766778
* Test the negated content regexp assertion.
767779
*
@@ -775,6 +787,18 @@ public function testAssertResponseNotRegExp()
775787
$this->assertResponseNotRegExp('/cant/');
776788
}
777789

790+
/**
791+
* Test negated content regexp assertion failing
792+
*
793+
* @expectedException \PHPUnit_Framework_AssertionFailedError
794+
* @expectedExceptionMessage No response set
795+
* @return void
796+
*/
797+
public function testAssertResponseNotRegExpNoResponse()
798+
{
799+
$this->assertResponseNotRegExp('/cont/');
800+
}
801+
778802
/**
779803
* Test that works in tandem with testEventManagerReset2 to
780804
* test the EventManager reset.

0 commit comments

Comments
 (0)