You are here

public function PhpunitCompatibilityTraitTest::testSetExpectedException in Drupal 8

Tests that setExpectedException is available.

@covers ::setExpectedException @group legacy @expectedDeprecation \Drupal\Tests\PhpunitCompatibilityTrait:setExpectedException() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Backward compatibility for PHPUnit 4 will no longer be supported. See https://www.drupal.org/node/3056869

File

core/tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php, line 33

Class

PhpunitCompatibilityTraitTest
Tests the PHPUnit forward compatibility trait.

Namespace

Drupal\Tests

Code

public function testSetExpectedException() {
  $expectedMessage = "Expected message";
  $expectedCode = 100;
  $this
    ->setExpectedException(\Exception::class, $expectedMessage, $expectedCode);
  throw new \Exception($expectedMessage, $expectedCode);
}