| @@ 134-151 (lines=18) @@ | ||
| 131 | /** |
|
| 132 | * testIgnoreException. |
|
| 133 | */ |
|
| 134 | public function testIgnoreAllException() |
|
| 135 | { |
|
| 136 | $breaker = new Breaker( |
|
| 137 | 'simple_echo', |
|
| 138 | ['ignore_exceptions' => true] |
|
| 139 | ); |
|
| 140 | $hello = 'eljam'; |
|
| 141 | ||
| 142 | $fn = function () use ($hello) { |
|
| 143 | throw new CustomException("An error as occurred"); |
|
| 144 | ||
| 145 | return $hello; |
|
| 146 | }; |
|
| 147 | ||
| 148 | $result = $breaker->protect($fn); |
|
| 149 | ||
| 150 | $this->assertNull($result); |
|
| 151 | } |
|
| 152 | ||
| 153 | /** |
|
| 154 | * testThrowCustomException. |
|
| @@ 156-172 (lines=17) @@ | ||
| 153 | /** |
|
| 154 | * testThrowCustomException. |
|
| 155 | */ |
|
| 156 | public function testThrowCustomException() |
|
| 157 | { |
|
| 158 | $breaker = new Breaker( |
|
| 159 | 'custom_exception' |
|
| 160 | ); |
|
| 161 | $hello = 'eljam'; |
|
| 162 | ||
| 163 | $this->setExpectedException('Eljam\CircuitBreaker\Exception\CustomException'); |
|
| 164 | ||
| 165 | $fn = function () use ($hello) { |
|
| 166 | throw new CustomException("An error as occurred"); |
|
| 167 | ||
| 168 | return $hello; |
|
| 169 | }; |
|
| 170 | ||
| 171 | $breaker->protect($fn); |
|
| 172 | } |
|
| 173 | ||
| 174 | public function testAllowedException() |
|
| 175 | { |
|