Skip to content

Commit

Permalink
Adds andThrows alias for andThrow
Browse files Browse the repository at this point in the history
I think it sits better with the newer syntax

$spy
    ->allows()
    ->foo()
    ->andThrows(new Exception());
  • Loading branch information
davedevelopment committed Sep 15, 2017
1 parent c569e68 commit 89db0ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/Mockery/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ public function andThrow($exception, $message = '', $code = 0, \Exception $previ
return $this;
}

public function andThrows($exception, $message = '', $code = 0, \Exception $previous = null)
{
return $this->andThrow($exception, $message, $code, $previous);
}

/**
* Set Exception classes to be thrown
*
Expand Down
9 changes: 9 additions & 0 deletions tests/Mockery/ExpectationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ public function testThrowsException()
Mockery::close();
}

/** @test */
public function and_throws_is_an_alias_to_and_throw()
{
$this->mock->shouldReceive('foo')->andThrows(new OutOfBoundsException);

$this->expectException(OutOfBoundsException::class);
$this->mock->foo();
}

/**
* @test
* @requires PHP 7.0.0
Expand Down

0 comments on commit 89db0ca

Please sign in to comment.