Skip to content

Commit ce5079c

Browse files
committed
Fix mock client strategy
- The Strategy returned a invalid array earlier. >The return value is always an array with zero or more elements. >Each element is an array with two keys >['class' => string, 'condition' => mixed] - Added entry in CHANGELOG as well
1 parent cc5669d commit ce5079c

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
## Unreleased
55

6+
- MockClientStategy class fixed
7+
68
## 1.2.0 - 2017-02-12
79

810
### Added
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace spec\Http\Discovery\Strategy;
4+
5+
use Http\Client\HttpClient;
6+
use Http\Discovery\ClassDiscovery;
7+
use Http\Discovery\Strategy\DiscoveryStrategy;
8+
use Http\Discovery\Strategy;
9+
use PhpSpec\ObjectBehavior;
10+
use spec\Http\Discovery\Helper\DiscoveryHelper;
11+
12+
class MockClientStrategySpec extends ObjectBehavior
13+
{
14+
function let()
15+
{
16+
ClassDiscovery::setStrategies([Strategy\MockClientStrategy::class]);
17+
}
18+
19+
function it_should_return_the_mock_client(DiscoveryStrategy $strategy)
20+
{
21+
$candidates = $this->getCandidates(HttpClient::class);
22+
$candidates->shouldBeArray();
23+
$candidates->shouldHaveCount(1);
24+
}
25+
}

src/Strategy/MockClientStrategy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class MockClientStrategy implements DiscoveryStrategy
1818
public static function getCandidates($type)
1919
{
2020
return ($type === HttpClient::class)
21-
? ['class' => Mock::class, 'condition' => Mock::class]
21+
? [['class' => Mock::class, 'condition' => Mock::class]]
2222
: [];
2323
}
2424
}

0 commit comments

Comments
 (0)