annotate vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Stub/Exception.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
rev   line source
Chris@0 1 <?php
Chris@0 2 /*
Chris@0 3 * This file is part of the PHPUnit_MockObject package.
Chris@0 4 *
Chris@0 5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
Chris@0 6 *
Chris@0 7 * For the full copyright and license information, please view the LICENSE
Chris@0 8 * file that was distributed with this source code.
Chris@0 9 */
Chris@0 10
Chris@0 11 use SebastianBergmann\Exporter\Exporter;
Chris@0 12
Chris@0 13 /**
Chris@0 14 * Stubs a method by raising a user-defined exception.
Chris@0 15 *
Chris@0 16 * @since Class available since Release 1.0.0
Chris@0 17 */
Chris@0 18 class PHPUnit_Framework_MockObject_Stub_Exception implements PHPUnit_Framework_MockObject_Stub
Chris@0 19 {
Chris@0 20 protected $exception;
Chris@0 21
Chris@0 22 public function __construct(Exception $exception)
Chris@0 23 {
Chris@0 24 $this->exception = $exception;
Chris@0 25 }
Chris@0 26
Chris@0 27 public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
Chris@0 28 {
Chris@0 29 throw $this->exception;
Chris@0 30 }
Chris@0 31
Chris@0 32 public function toString()
Chris@0 33 {
Chris@0 34 $exporter = new Exporter;
Chris@0 35
Chris@0 36 return sprintf(
Chris@0 37 'raise user-specified exception %s',
Chris@0 38 $exporter->export($this->exception)
Chris@0 39 );
Chris@0 40 }
Chris@0 41 }