Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: use SebastianBergmann\Exporter\Exporter; Chris@0: Chris@0: /** Chris@0: * Stubs a method by raising a user-defined exception. Chris@0: * Chris@0: * @since Class available since Release 1.0.0 Chris@0: */ Chris@0: class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_MockObject_Stub Chris@0: { Chris@0: protected $exception; Chris@0: Chris@0: public function __construct(Exception $exception) Chris@0: { Chris@0: $this->exception = $exception; Chris@0: } Chris@0: Chris@0: public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) Chris@0: { Chris@0: throw $this->exception; Chris@0: } Chris@0: Chris@0: public function toString() Chris@0: { Chris@0: $exporter = new Exporter; Chris@0: Chris@0: return sprintf( Chris@0: 'raise user-specified exception %s', Chris@0: $exporter->export($this->exception) Chris@0: ); Chris@0: } Chris@0: }