Browse Source

Refactor to use helper method + test coverage.

Refs #9842
Refs #9847
Mark Story 9 years ago
parent
commit
fc2d1f4fc8

+ 2 - 2
src/TestSuite/IntegrationTestCase.php

@@ -879,7 +879,7 @@ abstract class IntegrationTestCase extends TestCase
         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);
     }
 
     /**
@@ -894,7 +894,7 @@ abstract class IntegrationTestCase extends TestCase
         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);
     }
 
     /**

+ 24 - 0
tests/TestCase/TestSuite/IntegrationTestCaseTest.php

@@ -763,6 +763,18 @@ class IntegrationTestCaseTest extends IntegrationTestCase
     }
 
     /**
+     * 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.
      *
      * @return void
@@ -776,6 +788,18 @@ class IntegrationTestCaseTest extends IntegrationTestCase
     }
 
     /**
+     * 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.
      *