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