Last active
December 16, 2015 10:19
-
-
Save tamakiii/5418948 to your computer and use it in GitHub Desktop.
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 Hoge | |
{ | |
/** | |
* "ID" が大文字."Id" ではない | |
*/ | |
public function getID() | |
{ | |
return 123; | |
} | |
} | |
class HogeTest extends PHPUnit_Framework_TestCase | |
{ | |
public function test_HogeのgetIdの振る舞いが適切に書き換えられない() | |
{ | |
// 実オブジェクトでは呼び出せる | |
$hoge = new Hoge; | |
var_dump($hoge->getId()); # => 123 | |
// モック化すると… | |
$hoge = Phake::mock('Hoge'); | |
Phake::when($hoge)->getId()->thenReturn(1); | |
var_dump($hoge->getId()); # => null | |
Phake::verify($hoge)->getId(); // 当然これも通らない | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment