Skip to content

Instantly share code, notes, and snippets.

@isidromerayo
Created February 6, 2012 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isidromerayo/1753909 to your computer and use it in GitHub Desktop.
Save isidromerayo/1753909 to your computer and use it in GitHub Desktop.
Mockery examples
<?php
/**
* @expectedException OutOfBoundsException
*/
public function testThrowsException()
{
$mock = m::mock('MyMockedClass');
$mock->shouldReceive('foo')->andThrow(new OutOfBoundsException);
$mock->foo();
}
<?php
public function testPHPUnitMock() {
$mock = m::mock('MyMockedClass');
$mock->shouldReceive('fooWithArgument')->with('foo')->ordered();
$mock->shouldReceive('fooWithArgument')->with('bar')->ordered();
$mock->fooWithArgument('foo');
$mock->fooWithArgument('bar');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment