Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?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