Skip to content

Instantly share code, notes, and snippets.

@gquemener
Created July 5, 2013 13:26
Show Gist options
  • Save gquemener/5934507 to your computer and use it in GitHub Desktop.
Save gquemener/5934507 to your computer and use it in GitHub Desktop.
Mocking any object methods with mockery
<?php
/**
* @param stdClass $object
*/
function it_should_do_stuff($object)
{
$object->getBar()->willReturn('foo');
$stuffedObject = $this->doStuff($object);
$stuffedObject->getBar()->shouldReturn('FOO');
}
// Like that, no need to create some spec objects
@everzet
Copy link

everzet commented Jul 5, 2013

This also clearly illustrates why both me and @MarcelloDuarte hate this established convention about Interface suffix for interfaces. Don't do that and life would be much easier!

@gquemener
Copy link
Author

Damn, I didn't see your answer 'til today @everzet, thanks for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment