Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Forked from anonymous/gist:4409376
Last active December 10, 2015 08:38
Show Gist options
  • Save robertbasic/4409408 to your computer and use it in GitHub Desktop.
Save robertbasic/4409408 to your computer and use it in GitHub Desktop.
<?php
class MyClass
{
public function foo($paramA, $paramB)
{
return $paramA . $paramB;
}
public function bar($paramA, $paramB)
{
// more crap here i don't care about
// .....
// and then the important part
return $this->foo($paramA, $paramB);
}
}
class MyClassToMockTest
{
public function getMyClassMock()
{
$myClass = new MyClass();
$mockedClass = \Mockery::mock($myClass);
$mockedClass->shouldRecevice('bar')
->with(\Mockery::any(), \Mockery::any())
->andReturnUsing( function($paramA, $paramB) use ($mockedClass) {
// this will fail, so i am looking for a pointer on how to make it work
return $mockedClass->foo($paramA, $paramB);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment