Skip to content

Instantly share code, notes, and snippets.

@shoyan
Created August 20, 2013 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoyan/6277446 to your computer and use it in GitHub Desktop.
Save shoyan/6277446 to your computer and use it in GitHub Desktop.
簡単なモックのサンプル
<?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