From b08a8df4daf28405df8a1c193f2f0e89a2c72407 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 19 Apr 2022 15:02:48 -0700 Subject: [PATCH] (REF) HttpTestTrait - Promote `assertBodyRegexp()` from `AllFlowsTest` to `HttpTestTrait` --- Civi/Test/HttpTestTrait.php | 16 ++++++++++++++++ .../tests/phpunit/Civi/Authx/AllFlowsTest.php | 11 ----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Civi/Test/HttpTestTrait.php b/Civi/Test/HttpTestTrait.php index 99e6eb122e..0f6637a58c 100644 --- a/Civi/Test/HttpTestTrait.php +++ b/Civi/Test/HttpTestTrait.php @@ -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 diff --git a/ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php b/ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php index 3b63dda50a..829519037f 100644 --- a/ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php +++ b/ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php @@ -777,17 +777,6 @@ class AllFlowsTest extends \PHPUnit\Framework\TestCase implements EndToEndInterf return $this; } - /** - * @param $regexp - * @param \Psr\Http\Message\ResponseInterface $response - */ - private function assertBodyRegexp($regexp, $response = NULL) { - $response = $this->resolveResponse($response); - $this->assertRegexp($regexp, (string) $response->getBody(), - 'Response body does not match pattern' . $this->formatFailure($response)); - return $this; - } - /** * @return int * @throws \CiviCRM_API3_Exception -- 2.25.1