| @@ 257-271 (lines=15) @@ | ||
| 254 | $enumMap->setFlags(5); |
|
| 255 | } |
|
| 256 | ||
| 257 | public function testCurrentThrowsRuntimeExceptionOnInvalidFlag() |
|
| 258 | { |
|
| 259 | $enumMap = new EnumMap('MabeEnumTest\TestAsset\EnumBasic'); |
|
| 260 | $enumMap->attach(EnumBasic::ONE()); |
|
| 261 | $enumMap->rewind(); |
|
| 262 | ||
| 263 | // change internal flags to an invalid current flag |
|
| 264 | $reflectionClass = new ReflectionClass($enumMap); |
|
| 265 | $reflectionProp = $reflectionClass->getProperty('flags'); |
|
| 266 | $reflectionProp->setAccessible(true); |
|
| 267 | $reflectionProp->setValue($enumMap, 0); |
|
| 268 | ||
| 269 | $this->setExpectedException('RuntimeException'); |
|
| 270 | $enumMap->current(); |
|
| 271 | } |
|
| 272 | ||
| 273 | public function testKeyThrowsRuntimeExceptionOnInvalidFlag() |
|
| 274 | { |
|
| @@ 273-287 (lines=15) @@ | ||
| 270 | $enumMap->current(); |
|
| 271 | } |
|
| 272 | ||
| 273 | public function testKeyThrowsRuntimeExceptionOnInvalidFlag() |
|
| 274 | { |
|
| 275 | $enumMap = new EnumMap('MabeEnumTest\TestAsset\EnumBasic'); |
|
| 276 | $enumMap->attach(EnumBasic::ONE()); |
|
| 277 | $enumMap->rewind(); |
|
| 278 | ||
| 279 | // change internal flags to an invalid current flag |
|
| 280 | $reflectionClass = new ReflectionClass($enumMap); |
|
| 281 | $reflectionProp = $reflectionClass->getProperty('flags'); |
|
| 282 | $reflectionProp->setAccessible(true); |
|
| 283 | $reflectionProp->setValue($enumMap, 0); |
|
| 284 | ||
| 285 | $this->setExpectedException('RuntimeException'); |
|
| 286 | $enumMap->key(); |
|
| 287 | } |
|
| 288 | ||
| 289 | public function testSetFlagsThrowsInvalidArgumentExceptionOnUnsupportedCurrentFlag() |
|
| 290 | { |
|
| @@ 246-258 (lines=13) @@ | ||
| 243 | $this->assertSame($enum1, $enum2); |
|
| 244 | } |
|
| 245 | ||
| 246 | public function testCloneNotCallableAndThrowsLogicException() |
|
| 247 | { |
|
| 248 | $enum = EnumBasic::ONE(); |
|
| 249 | ||
| 250 | $reflectionClass = new ReflectionClass($enum); |
|
| 251 | $reflectionMethod = $reflectionClass->getMethod('__clone'); |
|
| 252 | $this->assertTrue($reflectionMethod->isPrivate(), 'The method __clone must be private'); |
|
| 253 | $this->assertTrue($reflectionMethod->isFinal(), 'The method __clone must be final'); |
|
| 254 | ||
| 255 | $reflectionMethod->setAccessible(true); |
|
| 256 | $this->setExpectedException('LogicException'); |
|
| 257 | $reflectionMethod->invoke($enum); |
|
| 258 | } |
|
| 259 | ||
| 260 | public function testNotSerializable() |
|
| 261 | { |
|