Merge pull request #24109 from yashodha/reports_improvements
[civicrm-core.git] / Civi / Test / HttpTestTrait.php
index 99e6eb122eff169e6cd1c0cfbda75ff4db0a576a..0f6637a58c116422d8de3d260736a64fad377e5a 100644 (file)
@@ -145,6 +145,22 @@ trait HttpTestTrait {
     return $this;
   }
 
+  /**
+   * @param string $regexp
+   * @param \Psr\Http\Message\ResponseInterface $response
+   * @param string $message
+   */
+  protected function assertBodyRegexp($regexp, $response = NULL, $message = NULL) {
+    if ($message) {
+      $message .= "\n";
+    }
+
+    $response = $this->resolveResponse($response);
+    $this->assertRegexp($regexp, (string) $response->getBody(),
+      $message . 'Response body does not match pattern' . $this->formatFailure($response));
+    return $this;
+  }
+
   /**
    * @param \Psr\Http\Message\ResponseInterface|null $response
    * @return \Psr\Http\Message\ResponseInterface