Browse Source

Added a ignoreCase flag to the assertResponseContains test helper

Viraj Khatavkar 8 years ago
parent
commit
43958561cd

+ 3 - 2
src/TestSuite/IntegrationTestCase.php

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

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

@@ -828,6 +828,19 @@ class IntegrationTestCaseTest extends IntegrationTestCase
     }
 
     /**
+     * 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.
      *
      * @return void