Created
April 11, 2011 18:15
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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