Created
August 20, 2013 05:37
-
-
Save shoyan/6277446 to your computer and use it in GitHub Desktop.
簡単なモックのサンプル
This file contains hidden or 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 SimpleMock | |
{ | |
public $returnValue = array(); | |
public function __call($method, $args) | |
{ | |
if (isset($this->returnValue[$method])) { | |
return $this->returnValue[$method]; | |
} | |
return null; | |
} | |
public function setReturnValue($method, $val) | |
{ | |
$this->returnValue[$method] = $val; | |
} | |
} | |
$m = new SimpleMock(); | |
var_dump($m->walk()); | |
$m->setReturnValue('walk', 'walking!'); | |
var_dump($m->walk()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment