Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/src/Stub/Exception.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 | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the phpunit-mock-objects package. | |
4 * | |
5 * (c) Sebastian Bergmann <sebastian@phpunit.de> | |
6 * | |
7 * For the full copyright and license information, please view the LICENSE | |
8 * file that was distributed with this source code. | |
9 */ | |
10 namespace PHPUnit\Framework\MockObject\Stub; | |
11 | |
12 use PHPUnit\Framework\MockObject\Invocation; | |
13 use PHPUnit\Framework\MockObject\Stub; | |
14 use SebastianBergmann\Exporter\Exporter; | |
15 | |
16 /** | |
17 * Stubs a method by raising a user-defined exception. | |
18 */ | |
19 class Exception implements Stub | |
20 { | |
21 private $exception; | |
22 | |
23 public function __construct(\Throwable $exception) | |
24 { | |
25 $this->exception = $exception; | |
26 } | |
27 | |
28 public function invoke(Invocation $invocation) | |
29 { | |
30 throw $this->exception; | |
31 } | |
32 | |
33 public function toString() | |
34 { | |
35 $exporter = new Exporter; | |
36 | |
37 return \sprintf( | |
38 'raise user-specified exception %s', | |
39 $exporter->export($this->exception) | |
40 ); | |
41 } | |
42 } |