Skip to content

Instantly share code, notes, and snippets.

@rdohms
Created April 11, 2011 18:15
Show Gist options
  • Save rdohms/913974 to your computer and use it in GitHub Desktop.
Save rdohms/913974 to your computer and use it in GitHub Desktop.
Why does mocking not work when the mocked method is private and called from inside the class?
<?php
class A
{
public function doFirst()
{
return $this->doSecond();
}
private function doSecond()
{
return false;
}
}
$a = new A();
$mock = Mockery::mock($a);
$mock->shouldReceive('doSecond')->andReturn(true);
var_dump($mock->doFirst()); //Expected: true, got false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment