From: Seamus Lee <seamuslee001@gmail.com>
Date: Sun, 5 May 2019 01:43:12 +0000 (+1000)
Subject: Fix Invalid asset builder test by using guzzle
X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bfbd33be19ded2bd6d4ceb3f288b4bdd501fba79;p=civicrm-core.git

Fix Invalid asset builder test by using guzzle
---

diff --git a/tests/phpunit/E2E/Core/AssetBuilderTest.php b/tests/phpunit/E2E/Core/AssetBuilderTest.php
index 19df9a3c1c..4e5e0bac0c 100644
--- a/tests/phpunit/E2E/Core/AssetBuilderTest.php
+++ b/tests/phpunit/E2E/Core/AssetBuilderTest.php
@@ -162,9 +162,14 @@ class AssetBuilderTest extends \CiviEndToEndTestCase {
   public function testInvalid() {
     \Civi::service('asset_builder')->setCacheEnabled(FALSE);
     $url = \Civi::service('asset_builder')->getUrl('invalid.json');
-    $this->assertEmpty(file_get_contents($url));
-    $this->assertNotEmpty(preg_grep(';HTTP/1.1 404;', $http_response_header),
-      'Expect to find HTTP 404. Found: ' . json_encode(preg_grep(';^HTTP;', $http_response_header)));
+    try {
+      $guzzleClient = new \GuzzleHttp\Client();
+      $guzzleResponse = $guzzleClient->request('GET', $url, array('timeout' => 1));
+    }
+    catch (\GuzzleHttp\Exception\ClientException $e) {
+      $this->assertNotEmpty(preg_match(';404;', $e->getMessage()),
+        'Expect to find HTTP 404. Found: ' . json_encode(preg_match(';^HTTP;', $e->getMessage())));
+    }
   }
 
 }