26
26
*/
27
27
class EnumTest extends TestCase
28
28
{
29
- public function setUp ()
30
- {
31
- $ this ->resetStaticEnumProps ();
32
- }
33
-
34
- public function tearDown ()
35
- {
36
- assert_options (ASSERT_ACTIVE , 1 );
37
- }
38
-
39
29
/**
40
30
* Un-initialize all known enumerations
41
31
*/
@@ -233,7 +223,7 @@ public function testGetNamesConstantsNotDetected()
233
223
$ this ->assertSame ($ expectedNames [$ i ], $ names [$ i ]);
234
224
}
235
225
}
236
-
226
+
237
227
public function testGetOrdinals ()
238
228
{
239
229
$ constants = EnumInheritance::getConstants ();
@@ -325,10 +315,15 @@ public function testEnabledAssertAmbiguousEnumeratorValues()
325
315
326
316
public function testDisabledAssertAmbiguousEnumeratorValues ()
327
317
{
328
- assert_options (ASSERT_ACTIVE , 0 );
329
318
$ this ->expectException (InvalidArgumentException::class);
330
319
331
- EnumAmbiguous::get ('unknown ' );
320
+ try {
321
+ assert_options (ASSERT_ACTIVE , 0 );
322
+ EnumAmbiguous::get ('unknown ' );
323
+ } catch (\Exception $ e ) {
324
+ assert_options (ASSERT_ACTIVE , 1 );
325
+ throw $ e ;
326
+ }
332
327
}
333
328
334
329
public function testExtendedEnabledAssertAmbiguousEnumeratorValues ()
@@ -345,10 +340,15 @@ public function testExtendedEnabledAssertAmbiguousEnumeratorValues()
345
340
346
341
public function testExtendedDisabledAssertAmbiguousEnumeratorValues ()
347
342
{
348
- assert_options (ASSERT_ACTIVE , 0 );
349
343
$ this ->expectException (InvalidArgumentException::class);
350
344
351
- EnumExtendedAmbiguous::get ('unknown ' );
345
+ try {
346
+ assert_options (ASSERT_ACTIVE , 0 );
347
+ EnumExtendedAmbiguous::get ('unknown ' );
348
+ } catch (\Exception $ e ) {
349
+ assert_options (ASSERT_ACTIVE , 1 );
350
+ throw $ e ;
351
+ }
352
352
}
353
353
354
354
public function testSingleton ()
@@ -364,12 +364,10 @@ public function testCloneNotCallableAndThrowsLogicException()
364
364
365
365
$ reflectionClass = new ReflectionClass ($ enum );
366
366
$ reflectionMethod = $ reflectionClass ->getMethod ('__clone ' );
367
- $ this ->assertTrue ($ reflectionMethod ->isPrivate (), 'The method __clone must be private ' );
368
367
$ this ->assertTrue ($ reflectionMethod ->isFinal (), 'The method __clone must be final ' );
369
368
370
- $ reflectionMethod ->setAccessible (true );
371
369
$ this ->expectException (LogicException::class);
372
- $ reflectionMethod -> invoke ( $ enum) ;
370
+ clone $ enum ;
373
371
}
374
372
375
373
public function testNotSerializable ()
@@ -430,7 +428,7 @@ public function testConstVisibility()
430
428
'PUB ' => ConstVisibilityEnum::PUB ,
431
429
), $ constants );
432
430
}
433
-
431
+
434
432
public function testConstVisibilityExtended ()
435
433
{
436
434
if (PHP_VERSION_ID < 70100 ) {
0 commit comments