Skip to content

Commit

Permalink
Relax HttpClient req
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed May 18, 2024
1 parent ea999c9 commit ac3a9a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
],
"require": {
"php": ">=8.3",
"symfony/http-client": "^7.1",
"symfony/http-client": "^7.0",
"webmozart/assert": "^1.11"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.56",
"phpunit/phpunit": "^11.2",
"symfony/var-dumper": "^7.1"
"symfony/var-dumper": "^7.0"
},
"prefer-stable": true,
"minimum-stability": "dev",
Expand Down
11 changes: 9 additions & 2 deletions tests/PageSpeedApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\JsonMockResponse;
use Symfony\Component\HttpClient\Response\MockResponse;

#[CoversClass(PageSpeedApi::class)]
class PageSpeedApiTest extends TestCase
{
public function testAnalysis(): void
{
$response = JsonMockResponse::fromFile(__DIR__.'/Fixtures/response/example.com.json');
$response = new MockResponse(
file_get_contents(__DIR__.'/Fixtures/response/example.com.json'),
['response_headers' => ['content-type' => 'application/json']],
);
$api = new PageSpeedApi('API_KEY', new MockHttpClient($response));

$analysis = $api->analyse('https://example.com');
Expand Down Expand Up @@ -79,7 +83,10 @@ public static function provideInvalidParameters(): iterable

public function testAnalyseReturnsCorrectValues(): void
{
$response = JsonMockResponse::fromFile(__DIR__.'/Fixtures/response/example.com.json');
$response = new MockResponse(
file_get_contents(__DIR__.'/Fixtures/response/example.com.json'),
['response_headers' => ['content-type' => 'application/json']],
);
$api = new PageSpeedApi('API_KEY', new MockHttpClient($response));

$analysis = $api->analyse('https://example.com', Strategy::Desktop, 'en_US', [Category::Performance]);
Expand Down

0 comments on commit ac3a9a0

Please sign in to comment.