public function Util_TestTest::testGetExpectedException

File

drupal/core/vendor/phpunit/phpunit/Tests/Util/TestTest.php, line 62

Class

Util_TestTest
@package PHPUnit @author Sebastian Bergmann <sebastian@phpunit.de> @copyright 2001-2013 Sebastian Bergmann <sebastian@phpunit.de> @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License @link …

Code

public function testGetExpectedException() {
  $this
    ->assertSame(array(
    'class' => 'FooBarBaz',
    'code' => NULL,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testOne'));
  $this
    ->assertSame(array(
    'class' => 'Foo_Bar_Baz',
    'code' => NULL,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testTwo'));
  $this
    ->assertSame(array(
    'class' => 'Foo\\Bar\\Baz',
    'code' => NULL,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testThree'));
  $this
    ->assertSame(array(
    'class' => 'ほげ',
    'code' => NULL,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFour'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => 1234,
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFive'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => 1234,
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSix'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => 'ExceptionCode',
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSeven'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => 0,
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testEight'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => ExceptionTest::ERROR_CODE,
    'message' => ExceptionTest::ERROR_MESSAGE,
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testNine'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => NULL,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSingleLine'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => My\Space\ExceptionNamespaceTest::ERROR_CODE,
    'message' => My\Space\ExceptionNamespaceTest::ERROR_MESSAGE,
  ), PHPUnit_Util_Test::getExpectedException('My\\Space\\ExceptionNamespaceTest', 'testConstants'));

  // Ensure the Class::CONST expression is only evaluated when the constant really exists
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => 'ExceptionTest::UNKNOWN_CODE_CONSTANT',
    'message' => 'ExceptionTest::UNKNOWN_MESSAGE_CONSTANT',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testUnknownConstants'));
  $this
    ->assertSame(array(
    'class' => 'Class',
    'code' => 'My\\Space\\ExceptionNamespaceTest::UNKNOWN_CODE_CONSTANT',
    'message' => 'My\\Space\\ExceptionNamespaceTest::UNKNOWN_MESSAGE_CONSTANT',
  ), PHPUnit_Util_Test::getExpectedException('My\\Space\\ExceptionNamespaceTest', 'testUnknownConstants'));
}