diff --git a/tests/phpunit/E2E/Core/AssetBuilderTest.php b/tests/phpunit/E2E/Core/AssetBuilderTest.php index 19df9a3c1cd2..4e5e0bac0cae 100644 --- a/tests/phpunit/E2E/Core/AssetBuilderTest.php +++ b/tests/phpunit/E2E/Core/AssetBuilderTest.php @@ -162,9 +162,14 @@ public function testGetUrl_uncached($asset, $params, $expectedMimeType, $expecte 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()))); + } } }