diff --git a/spec/Strategy/MockClientStrategySpec.php b/spec/Strategy/MockClientStrategySpec.php index 6a7e121..5927660 100644 --- a/spec/Strategy/MockClientStrategySpec.php +++ b/spec/Strategy/MockClientStrategySpec.php @@ -2,6 +2,7 @@ namespace spec\Http\Discovery\Strategy; +use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Http\Discovery\ClassDiscovery; use Http\Discovery\Strategy\DiscoveryStrategy; @@ -22,4 +23,11 @@ function it_should_return_the_mock_client(DiscoveryStrategy $strategy) $candidates->shouldBeArray(); $candidates->shouldHaveCount(1); } + + function it_should_return_the_mock_client_as_async(DiscoveryStrategy $strategy) + { + $candidates = $this->getCandidates(HttpAsyncClient::class); + $candidates->shouldBeArray(); + $candidates->shouldHaveCount(1); + } } diff --git a/src/Strategy/MockClientStrategy.php b/src/Strategy/MockClientStrategy.php index 5744787..01143ba 100644 --- a/src/Strategy/MockClientStrategy.php +++ b/src/Strategy/MockClientStrategy.php @@ -2,6 +2,7 @@ namespace Http\Discovery\Strategy; +use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Http\Mock\Client as Mock; @@ -17,8 +18,12 @@ final class MockClientStrategy implements DiscoveryStrategy */ public static function getCandidates($type) { - return (HttpClient::class === $type) - ? [['class' => Mock::class, 'condition' => Mock::class]] - : []; + switch ($type) { + case HttpClient::class: + case HttpAsyncClient::class: + return [['class' => Mock::class, 'condition' => Mock::class]]; + default: + return []; + } } }