2626 */
2727class EnumTest extends TestCase
2828{
29- public function setUp ()
30- {
31- $ this ->resetStaticEnumProps ();
32- }
33-
34- public function tearDown ()
35- {
36- assert_options (ASSERT_ACTIVE , 1 );
37- }
38-
3929 /**
4030 * Un-initialize all known enumerations
4131 */
@@ -233,7 +223,7 @@ public function testGetNamesConstantsNotDetected()
233223 $ this ->assertSame ($ expectedNames [$ i ], $ names [$ i ]);
234224 }
235225 }
236-
226+
237227 public function testGetOrdinals ()
238228 {
239229 $ constants = EnumInheritance::getConstants ();
@@ -325,10 +315,15 @@ public function testEnabledAssertAmbiguousEnumeratorValues()
325315
326316 public function testDisabledAssertAmbiguousEnumeratorValues ()
327317 {
328- assert_options (ASSERT_ACTIVE , 0 );
329318 $ this ->expectException (InvalidArgumentException::class);
330319
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+ }
332327 }
333328
334329 public function testExtendedEnabledAssertAmbiguousEnumeratorValues ()
@@ -345,10 +340,15 @@ public function testExtendedEnabledAssertAmbiguousEnumeratorValues()
345340
346341 public function testExtendedDisabledAssertAmbiguousEnumeratorValues ()
347342 {
348- assert_options (ASSERT_ACTIVE , 0 );
349343 $ this ->expectException (InvalidArgumentException::class);
350344
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+ }
352352 }
353353
354354 public function testSingleton ()
@@ -364,12 +364,10 @@ public function testCloneNotCallableAndThrowsLogicException()
364364
365365 $ reflectionClass = new ReflectionClass ($ enum );
366366 $ reflectionMethod = $ reflectionClass ->getMethod ('__clone ' );
367- $ this ->assertTrue ($ reflectionMethod ->isPrivate (), 'The method __clone must be private ' );
368367 $ this ->assertTrue ($ reflectionMethod ->isFinal (), 'The method __clone must be final ' );
369368
370- $ reflectionMethod ->setAccessible (true );
371369 $ this ->expectException (LogicException::class);
372- $ reflectionMethod -> invoke ( $ enum) ;
370+ clone $ enum ;
373371 }
374372
375373 public function testNotSerializable ()
@@ -430,7 +428,7 @@ public function testConstVisibility()
430428 'PUB ' => ConstVisibilityEnum::PUB ,
431429 ), $ constants );
432430 }
433-
431+
434432 public function testConstVisibilityExtended ()
435433 {
436434 if (PHP_VERSION_ID < 70100 ) {
0 commit comments