Skip to content

Instantly share code, notes, and snippets.

@rickard2
Last active December 20, 2015 03:19
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 rickard2/6062801 to your computer and use it in GitHub Desktop.
Save rickard2/6062801 to your computer and use it in GitHub Desktop.
<?php
$mock = $this->getMockBuilder('SomeClass')->setMethods('foo')->getMock();
$foo = $mock->expects($this->exactly(2))->method('foo');
$object = new OtherClass($mock);
$foo->will($this->returnValue(true));
$result = $object->doStuff();
$this->assertEquals( ... , $result);
$foo->will($this->throwException(new Exception()));
$result = $object->doStuff();
$this->assertEquals( ... , $result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment