From ddf3911dacf86035001355b0260212d25d967a0e Mon Sep 17 00:00:00 2001 From: diosmosis Date: Thu, 29 Oct 2015 05:17:31 -0700 Subject: Do not remove URLs in API output during tests, instead replace it w/ hard-coded root URL. --- tests/PHPUnit/Framework/TestRequest/Response.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'tests/PHPUnit/Framework/TestRequest') diff --git a/tests/PHPUnit/Framework/TestRequest/Response.php b/tests/PHPUnit/Framework/TestRequest/Response.php index 22a12be8f0..daf76d72f4 100644 --- a/tests/PHPUnit/Framework/TestRequest/Response.php +++ b/tests/PHPUnit/Framework/TestRequest/Response.php @@ -115,7 +115,7 @@ class Response $apiResponse = $this->normalizeDecimalFields($apiResponse); $apiResponse = $this->normalizeEncodingPhp533($apiResponse); $apiResponse = $this->normalizeSpaces($apiResponse); - $apiResponse = $this->removePiwikUrl($apiResponse); + $apiResponse = $this->replacePiwikUrl($apiResponse); return $apiResponse; } @@ -265,8 +265,17 @@ class Response return $this->removeXmlFields($apiResponse, array('idsubdatatable_in_db')); } - private function removePiwikUrl($apiResponse) + /** + * To allow tests to pass no matter what port Piwik is on, we replace the test URL w/ another + * one in the response. We don't remove the URL outright, because then we would not be able + * to detect regressions where the root URL went missing. + * + * @param $apiResponse + * @return mixed + * @throws Exception + */ + private function replacePiwikUrl($apiResponse) { - return str_replace(Fixture::getRootUrl(), "", $apiResponse); + return str_replace(Fixture::getRootUrl(), "http://example.com/piwik/", $apiResponse); } } -- cgit v1.2.3