Skip to content

Commit

Permalink
Merge pull request #746 from robertbasic/fix/issue745
Browse files Browse the repository at this point in the history
Allow overriding count validators
  • Loading branch information
davedevelopment committed May 14, 2017
2 parents 4060b00 + 41796c1 commit f07e12f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/Mockery/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public function times($limit = null)
if (!is_int($limit)) {
throw new \InvalidArgumentException('The passed Times limit should be an integer value');
}
$this->_countValidators[] = new $this->_countValidatorClass($this, $limit);
$this->_countValidators[$this->_countValidatorClass] = new $this->_countValidatorClass($this, $limit);
$this->_countValidatorClass = 'Mockery\CountValidator\Exact';
return $this;
}
Expand Down
14 changes: 13 additions & 1 deletion tests/Mockery/AllowsExpectsSyntaxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function expectsSetsUpExpectationOfOneCall()
}

/** @test */
public function callVerificationCountCanBeOverridenAfterExpects()
public function callVerificationCountCanBeOverridenAfterExpectsThrowsExceptionWhenIncorrectNumberOfCalls()
{
$mock = m::mock();
$mock->expects()->foo(123)->twice();
Expand All @@ -106,6 +106,18 @@ public function callVerificationCountCanBeOverridenAfterExpects()
m::close();
}

/** @test */
public function callVerificationCountCanBeOverridenAfterExpects()
{
$mock = m::mock();
$mock->expects()->foo(123)->twice();

$mock->foo(123);
$mock->foo(123);

m::close();
}

/** @test */
public function generateSkipsExpectsMethodIfAlreadyExists()
{
Expand Down

0 comments on commit f07e12f

Please sign in to comment.