モックがHTTPステータスコードに応じた例外を投げるようにする

This commit is contained in:
shibafu 2019-09-10 22:35:36 +09:00
parent 2c4eaccf43
commit a10acdd481

View File

@ -5,6 +5,7 @@ namespace Tests\Unit\MetadataResolver;
use App\MetadataResolver\Resolver;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Monolog\Handler\AbstractHandler;
@ -41,7 +42,7 @@ trait CreateMockedResolver
$mockResponse = new Response($status, $headers, $responseText);
$this->handler = new MockHandler([$mockResponse]);
$client = new Client(['handler' => $this->handler]);
$client = new Client(['handler' => HandlerStack::create($this->handler)]);
$this->resolver = app()->make($resolverClass, ['client' => $client]);
return $this->resolver;