|
2 | 2 |
|
3 | 3 | namespace MabeEnumTest; |
4 | 4 |
|
| 5 | +use AssertionError; |
| 6 | +use Exception; |
5 | 7 | use InvalidArgumentException; |
6 | 8 | use LogicException; |
7 | 9 | use MabeEnum\Enum; |
@@ -274,15 +276,57 @@ public function testInstantiateUsingMagicMethod() |
274 | 276 | $this->assertSame(EnumInheritance::ONE, $enum->getValue()); |
275 | 277 | } |
276 | 278 |
|
277 | | - public function testAmbiguousConstantsThrowsLogicException() |
| 279 | + public function testEnabledAssertAmbiguousEnumeratorValues() |
278 | 280 | { |
279 | | - $this->expectException(LogicException::class); |
| 281 | + assert_options(ASSERT_ACTIVE, 1); |
| 282 | + assert_options(ASSERT_WARNING, 1); |
| 283 | + assert_options(ASSERT_BAIL, 0); |
| 284 | + assert_options(ASSERT_QUIET_EVAL, 0); |
| 285 | + if (\PHP_VERSION_ID >= 70000) { |
| 286 | + $this->expectException(AssertionError::class); |
| 287 | + } elseif (defined('HHVM_VERSION')) { |
| 288 | + // assertion error thrown on HHVM is buggy |
| 289 | + $this->expectException(Exception::class); |
| 290 | + } |
| 291 | + |
280 | 292 | EnumAmbiguous::get('unknown'); |
281 | 293 | } |
282 | 294 |
|
283 | | - public function testExtendedAmbiguousCanstantsThrowsLogicException() |
| 295 | + public function testDisabledAssertAmbiguousEnumeratorValues() |
284 | 296 | { |
285 | | - $this->expectException(LogicException::class); |
| 297 | + assert_options(ASSERT_ACTIVE, 0); |
| 298 | + assert_options(ASSERT_WARNING, 1); |
| 299 | + assert_options(ASSERT_BAIL, 0); |
| 300 | + assert_options(ASSERT_QUIET_EVAL, 0); |
| 301 | + $this->expectException(InvalidArgumentException::class); |
| 302 | + |
| 303 | + EnumAmbiguous::get('unknown'); |
| 304 | + } |
| 305 | + |
| 306 | + public function testExtendedEnabledAssertAmbiguousEnumeratorValues() |
| 307 | + { |
| 308 | + assert_options(ASSERT_ACTIVE, 1); |
| 309 | + assert_options(ASSERT_WARNING, 1); |
| 310 | + assert_options(ASSERT_BAIL, 0); |
| 311 | + assert_options(ASSERT_QUIET_EVAL, 0); |
| 312 | + if (\PHP_VERSION_ID >= 70000) { |
| 313 | + $this->expectException(AssertionError::class); |
| 314 | + } elseif (defined('HHVM_VERSION')) { |
| 315 | + // assertion error thrown on HHVM is buggy |
| 316 | + $this->expectException(Exception::class); |
| 317 | + } |
| 318 | + |
| 319 | + EnumExtendedAmbiguous::get('unknown'); |
| 320 | + } |
| 321 | + |
| 322 | + public function testExtendedDisabledAssertAmbiguousEnumeratorValues() |
| 323 | + { |
| 324 | + assert_options(ASSERT_ACTIVE, 0); |
| 325 | + assert_options(ASSERT_WARNING, 1); |
| 326 | + assert_options(ASSERT_BAIL, 0); |
| 327 | + assert_options(ASSERT_QUIET_EVAL, 0); |
| 328 | + $this->expectException(InvalidArgumentException::class); |
| 329 | + |
286 | 330 | EnumExtendedAmbiguous::get('unknown'); |
287 | 331 | } |
288 | 332 |
|
|
0 commit comments