You are here

public function InstantiatorTest::testNoticeOnUnSerializationException in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php \DoctrineTest\InstantiatorTest\InstantiatorTest::testNoticeOnUnSerializationException()

File

vendor/doctrine/instantiator/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php, line 97

Class

InstantiatorTest
Tests for { @author Marco Pivetta <ocramius@gmail.com>

Namespace

DoctrineTest\InstantiatorTest

Code

public function testNoticeOnUnSerializationException() {
  if (\PHP_VERSION_ID >= 50600) {
    $this
      ->markTestSkipped('PHP 5.6 supports `ReflectionClass#newInstanceWithoutConstructor()` for some internal classes');
  }
  try {
    $this->instantiator
      ->instantiate('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
    $this
      ->fail('No exception was raised');
  } catch (UnexpectedValueException $exception) {
    $wakeUpNoticesReflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
    $previous = $exception
      ->getPrevious();
    $this
      ->assertInstanceOf('Exception', $previous);

    // in PHP 5.4.29 and PHP 5.5.13, this case is not a notice, but an exception being thrown
    if (!(\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513)) {
      $this
        ->assertSame('Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset" ' . 'via un-serialization, since an error was triggered in file "' . $wakeUpNoticesReflection
        ->getFileName() . '" at line "36"', $exception
        ->getMessage());
      $this
        ->assertSame('Something went bananas while un-serializing this instance', $previous
        ->getMessage());
      $this
        ->assertSame(\E_USER_NOTICE, $previous
        ->getCode());
    }
  }
}