Mercurial > hg > isophonics-drupal-site
diff core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 7a779792577d |
children |
line wrap: on
line diff
--- a/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php Mon Apr 23 09:46:53 2018 +0100 @@ -48,7 +48,7 @@ * * @see https://www.drupal.org/node/2907725 */ - public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE, $callOriginalMethods = FALSE, $proxyTarget = NULL) { + public function getMock($originalClassName, $methods = [], array $arguments = [], $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE, $callOriginalMethods = FALSE, $proxyTarget = NULL) { if (!$this->supports('getMock')) { $mock = $this->getMockBuilder($originalClassName) ->setMethods($methods) @@ -117,6 +117,31 @@ } /** + * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. + * + * @param mixed $class + * The expected exception class. + * @param string $message + * The expected exception message. + * @param int $exception_code + * The expected exception code. + */ + public function setExpectedException($class, $message = '', $exception_code = NULL) { + if (method_exists($this, 'expectException')) { + $this->expectException($class); + if (!empty($message)) { + $this->expectExceptionMessage($message); + } + if ($exception_code !== NULL) { + $this->expectExceptionCode($exception_code); + } + } + else { + parent::setExpectedException($class, $message, $exception_code); + } + } + + /** * Checks if the trait is used in a class that has a method. * * @param string $method