Chemaclass /
stock-ticker
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Chemaclass\StockTickerTests\Unit; |
||
| 6 | |||
| 7 | use Symfony\Contracts\HttpClient\HttpClientInterface; |
||
| 8 | use Symfony\Contracts\HttpClient\ResponseInterface; |
||
| 9 | |||
| 10 | trait WithFakeHttpClient |
||
| 11 | { |
||
| 12 | private function mockHttpClient(string $responseBody = ''): HttpClientInterface |
||
| 13 | { |
||
| 14 | $response = $this->createMock(ResponseInterface::class); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 15 | $response->method('getContent')->willReturn($responseBody); |
||
| 16 | |||
| 17 | $httpClient = $this->createMock(HttpClientInterface::class); |
||
| 18 | $httpClient->method('request')->willReturn($response); |
||
| 19 | |||
| 20 | return $httpClient; |
||
| 21 | } |
||
| 22 | } |
||
| 23 |