3 * This file is part of the PHPUnit_MockObject package.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 use SebastianBergmann\Exporter\Exporter;
14 * Stubs a method by raising a user-defined exception.
16 * @since Class available since Release 1.0.0
18 class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_MockObject_Stub
22 public function __construct(Exception $exception)
24 $this->exception = $exception;
27 public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
29 throw $this->exception;
32 public function toString()
34 $exporter = new Exporter;
37 'raise user-specified exception %s',
38 $exporter->export($this->exception)