Mercurial > hg > isophonics-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
46 * @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. | 46 * @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. |
47 * Use \Drupal\Tests\PhpunitCompatibilityTrait::createMock() instead. | 47 * Use \Drupal\Tests\PhpunitCompatibilityTrait::createMock() instead. |
48 * | 48 * |
49 * @see https://www.drupal.org/node/2907725 | 49 * @see https://www.drupal.org/node/2907725 |
50 */ | 50 */ |
51 public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE, $callOriginalMethods = FALSE, $proxyTarget = NULL) { | 51 public function getMock($originalClassName, $methods = [], array $arguments = [], $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $cloneArguments = FALSE, $callOriginalMethods = FALSE, $proxyTarget = NULL) { |
52 if (!$this->supports('getMock')) { | 52 if (!$this->supports('getMock')) { |
53 $mock = $this->getMockBuilder($originalClassName) | 53 $mock = $this->getMockBuilder($originalClassName) |
54 ->setMethods($methods) | 54 ->setMethods($methods) |
55 ->setConstructorArgs($arguments) | 55 ->setConstructorArgs($arguments) |
56 ->setMockClassName($mockClassName) | 56 ->setMockClassName($mockClassName) |
115 return $this->getMock($originalClassName, [], [], '', FALSE, FALSE); | 115 return $this->getMock($originalClassName, [], [], '', FALSE, FALSE); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 /** | 119 /** |
120 * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
121 * | |
122 * @param mixed $class | |
123 * The expected exception class. | |
124 * @param string $message | |
125 * The expected exception message. | |
126 * @param int $exception_code | |
127 * The expected exception code. | |
128 */ | |
129 public function setExpectedException($class, $message = '', $exception_code = NULL) { | |
130 if (method_exists($this, 'expectException')) { | |
131 $this->expectException($class); | |
132 if (!empty($message)) { | |
133 $this->expectExceptionMessage($message); | |
134 } | |
135 if ($exception_code !== NULL) { | |
136 $this->expectExceptionCode($exception_code); | |
137 } | |
138 } | |
139 else { | |
140 parent::setExpectedException($class, $message, $exception_code); | |
141 } | |
142 } | |
143 | |
144 /** | |
120 * Checks if the trait is used in a class that has a method. | 145 * Checks if the trait is used in a class that has a method. |
121 * | 146 * |
122 * @param string $method | 147 * @param string $method |
123 * Method to check. | 148 * Method to check. |
124 * | 149 * |