You are here

public function Util_TestTest::testGetExpectedException in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpunit/phpunit/tests/Util/TestTest.php \Util_TestTest::testGetExpectedException()

@covers PHPUnit_Util_Test::getExpectedException @todo Split up in separate tests

File

vendor/phpunit/phpunit/tests/Util/TestTest.php, line 31

Class

Util_TestTest
@since Class available since Release 3.3.6

Code

public function testGetExpectedException() {
  $this
    ->assertArraySubset(array(
    'class' => 'FooBarBaz',
    'code' => null,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testOne'));
  $this
    ->assertArraySubset(array(
    'class' => 'Foo_Bar_Baz',
    'code' => null,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testTwo'));
  $this
    ->assertArraySubset(array(
    'class' => 'Foo\\Bar\\Baz',
    'code' => null,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testThree'));
  $this
    ->assertArraySubset(array(
    'class' => 'ほげ',
    'code' => null,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFour'));
  $this
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => 1234,
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFive'));
  $this
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => 1234,
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSix'));
  $this
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => 'ExceptionCode',
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSeven'));
  $this
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => 0,
    'message' => 'Message',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testEight'));
  $this
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => ExceptionTest::ERROR_CODE,
    'message' => ExceptionTest::ERROR_MESSAGE,
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testNine'));
  $this
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => null,
    'message' => '',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSingleLine'));
  $this
    ->assertArraySubset(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
    ->assertArraySubset(array(
    'class' => 'Class',
    'code' => 'ExceptionTest::UNKNOWN_CODE_CONSTANT',
    'message' => 'ExceptionTest::UNKNOWN_MESSAGE_CONSTANT',
  ), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testUnknownConstants'));
  $this
    ->assertArraySubset(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'));
}