Skip to content

Commit

Permalink
Merge 833f511 into 619f304
Browse files Browse the repository at this point in the history
  • Loading branch information
demsey2 committed Feb 18, 2014
2 parents 619f304 + 833f511 commit c29aa20
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
11 changes: 8 additions & 3 deletions library/Mockery/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public function matchArgs(array $args)
return false;
}
}

return true;
}

Expand Down Expand Up @@ -315,8 +316,7 @@ protected function _matchArg($expected, &$actual)
*/
public function with()
{
$this->_expectedArgs = func_get_args();
return $this;
return $this->withArgs(func_get_args());
}

/**
Expand All @@ -327,7 +327,11 @@ public function with()
*/
public function withArgs(array $args)
{
if (empty($args)) {
return $this->withNoArgs();
}
$this->_expectedArgs = $args;
$this->_noArgsExpectation = false;
return $this;
}

Expand All @@ -339,7 +343,8 @@ public function withArgs(array $args)
public function withNoArgs()
{
$this->_noArgsExpectation = true;
return $this->with();
$this->_expectedArgs = null;
return $this;
}

/**
Expand Down
20 changes: 19 additions & 1 deletion tests/Mockery/ExpectationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ public function testExpectsArgumentsArray()
$this->mock->foo(1, 2);
}

/**
* @expectedException \Mockery\Exception
*/
public function testExpectsArgumentsArrayThrowsExceptionIfPassedEmptyArray()
{
$this->mock->shouldReceive('foo')->withArgs(array());
$this->mock->foo(1, 2);
}

/**
* @expectedException \Mockery\Exception
*/
public function testExpectsArgumentsArrayThrowsExceptionIfNoArgumentsPassed()
{
$this->mock->shouldReceive('foo')->with();
$this->mock->foo(1);
}

/**
* @expectedException \Mockery\Exception
*/
Expand Down Expand Up @@ -1700,7 +1718,7 @@ public function testMockingDemeterChainsPassesMockeryExpectationToCompositeExpec
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @runInSeparateProcess
*/
*/
public function testPregMatchThrowsDelimiterWarningWithXdebugScreamTurnedOn()
{
if (!extension_loaded('xdebug')) {
Expand Down

0 comments on commit c29aa20

Please sign in to comment.