Browse Source

Add assertHeaderNotContains()

It was easy to do now that we have a constraint.
Mark Story 7 years ago
parent
commit
3b07ca11a8

+ 14 - 0
src/TestSuite/IntegrationTestTrait.php

@@ -909,6 +909,20 @@ trait IntegrationTestTrait
     }
 
     /**
+     * Asserts response header does not contain a string
+     *
+     * @param string $header The header to check
+     * @param string $content The content to check for.
+     * @param string $message The failure message that will be appended to the generated message.
+     * @return void
+     */
+    public function assertHeaderNotContains($header, $content, $message = '')
+    {
+        $this->assertThat(null, new HeaderSet($this->_response, $header), $message);
+        $this->assertThat($content, new HeaderNotContains($this->_response, $header), $message);
+    }
+
+    /**
      * Asserts content type
      *
      * @param string $type The content-type to check for.

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

@@ -1019,6 +1019,19 @@ class IntegrationTestTraitTest extends IntegrationTestCase
     }
 
     /**
+     * Test the header not contains assertion.
+     *
+     * @return void
+     */
+    public function testAssertHeaderNotContains()
+    {
+        $this->_response = new Response();
+        $this->_response = $this->_response->withHeader('Etag', 'abc123');
+
+        $this->assertHeaderNotContains('Etag', 'xyz');
+    }
+
+    /**
      * Test the content type assertion.
      *
      * @return void