Skip to content

Commit

Permalink
Merge pull request #519 from ciaranmcnulty/throwable-exceptions
Browse files Browse the repository at this point in the history
Make Prophecy Exceptions throwable
  • Loading branch information
ciaranmcnulty authored Jan 18, 2021
2 parents 245710e + c878a3d commit 7114670
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 7 additions & 8 deletions spec/Prophecy/Exception/Prediction/AggregateExceptionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace spec\Prophecy\Exception\Prediction;

use PhpSpec\ObjectBehavior;
use Prophecy\Exception\Prediction\FailedPredictionException;
use Prophecy\Exception\Prediction\PredictionException;
use Prophecy\Prophecy\ObjectProphecy;

Expand Down Expand Up @@ -30,18 +31,18 @@ function it_should_not_have_exceptions_at_the_beginning()
$this->getExceptions()->shouldHaveCount(0);
}

function it_should_append_exception_through_append_method(PredictionException $exception)
function it_should_append_exception_through_append_method()
{
$exception->getMessage()->willReturn('Exception #1');
$exception = new FailedPredictionException();

$this->append($exception);

$this->getExceptions()->shouldReturn(array($exception));
}

function it_should_update_message_during_append(PredictionException $exception)
function it_should_update_message_during_append()
{
$exception->getMessage()->willReturn('Exception #1');
$exception = new FailedPredictionException('Exception #1');

$this->append($exception);

Expand All @@ -52,12 +53,10 @@ function it_should_update_message_during_append_more_exceptions(
PredictionException $exception1,
PredictionException $exception2
) {
$exception1->getMessage()->willReturn('Exception #1');
$exception2->getMessage()->willReturn('Exception #2');
$exception1 = new FailedPredictionException('Exception #1');
$exception2 = new FailedPredictionException('Exception #2');

$this->append($exception1);
$this->getMessage()->shouldReturn('Exception #1');

$this->append($exception2);
$this->getMessage()->shouldReturn("Exception #1\nException #2");
}
Expand Down
6 changes: 1 addition & 5 deletions src/Prophecy/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
interface Exception
interface Exception extends \Throwable
{
/**
* @return string
*/
public function getMessage();
}

0 comments on commit 7114670

Please sign in to comment.