public function PhpunitCompatibilityTrait::setExpectedException in Drupal 8
Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
Parameters
mixed $class: The expected exception class.
string $message: The expected exception message.
int $exception_code: The expected exception code.
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 also
https://www.drupal.org/node/3056869
1 call to PhpunitCompatibilityTrait::setExpectedException()
- PhpunitCompatibilityTraitTest::testSetExpectedException in core/
tests/ Drupal/ Tests/ PhpunitCompatibilityTraitTest.php - Tests that setExpectedException is available.
File
- core/
tests/ Drupal/ Tests/ PhpunitCompatibilityTrait.php, line 116
Class
- PhpunitCompatibilityTrait
- Makes Drupal's test API forward compatible with multiple versions of PHPUnit.
Namespace
Drupal\TestsCode
public function setExpectedException($class, $message = '', $exception_code = NULL) {
@trigger_error('\\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', E_USER_DEPRECATED);
$this
->expectException($class);
if (!empty($message)) {
$this
->expectExceptionMessage($message);
}
if ($exception_code !== NULL) {
$this
->expectExceptionCode($exception_code);
}
}