Skip to content

Commit

Permalink
Fix Invalid asset builder test by using guzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed May 30, 2019
1 parent 857b679 commit b1616ad
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/phpunit/E2E/Core/AssetBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}
}

}

0 comments on commit b1616ad

Please sign in to comment.