Conditions | 1 |
Paths | 1 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public function it_creates_a_default_circuit_breaker() |
||
11 | { |
||
12 | $maxFailures = 1; |
||
13 | $circuitBreaker = Factory::default($maxFailures); |
||
14 | |||
15 | $this->assertTrue( |
||
16 | $circuitBreaker->isAvailable("host:port"), |
||
17 | "service is available until reach the number of failures" |
||
18 | ); |
||
19 | |||
20 | $circuitBreaker->reportFailure("host:port"); |
||
21 | |||
22 | $this->assertFalse( |
||
23 | $circuitBreaker->isAvailable("host:port"), |
||
24 | "after reach the number of failures, the service is not available" |
||
25 | ); |
||
26 | |||
27 | $circuitBreaker->reportSuccess("host:port"); |
||
28 | |||
29 | $this->assertTrue( |
||
30 | $circuitBreaker->isAvailable("host:port"), |
||
31 | "successes decrease the number of failures, eventually closing the circuit" |
||
32 | ); |
||
36 |