Skip to content

Commit da11a15

Browse files
committed
added test for __clone
1 parent 93e123f commit da11a15

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/MabeEnumTest/EnumTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,18 @@ public function testClear()
100100
$this->assertNotSame($enum1, $enum2);
101101
$this->assertSame($enum2, $enum3);
102102
}
103+
104+
public function testCloneNotCallableAndThrowsLogicException()
105+
{
106+
$enum = MabeEnumTest_TestAsset_EnumWithoutDefaultValue::ONE();
107+
108+
$reflectionClass = new ReflectionClass($enum);
109+
$reflectionMethod = $reflectionClass->getMethod('__clone');
110+
$this->assertTrue($reflectionMethod->isPrivate(), 'The method __clone must be private');
111+
$this->assertTrue($reflectionMethod->isFinal(), 'The method __clone must be final');
112+
113+
$reflectionMethod->setAccessible(true);
114+
$this->setExpectedException('LogicException');
115+
$reflectionMethod->invoke($enum);
116+
}
103117
}

0 commit comments

Comments
 (0)