| 1 | <?php |
||
| 3 | class TestMock |
||
| 4 | { |
||
| 5 | private $target; |
||
| 6 | |||
| 7 | private function __construct($target) |
||
| 8 | { |
||
| 9 | $this->target = $target; |
||
| 10 | } |
||
| 11 | |||
| 12 | public static function on($target) |
||
| 13 | { |
||
| 14 | return new self($target); |
||
| 15 | } |
||
| 16 | |||
| 17 | public function __call($name, $args) |
||
| 18 | { |
||
| 19 | $method = new ReflectionMethod($this->target, $name); |
||
| 20 | $method->setAccessible(true); |
||
| 21 | |||
| 22 | return $method->invokeArgs($this->target, $args); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function __get($name) |
||
| 26 | { |
||
| 27 | $method = new ReflectionProperty($this->target, $name); |
||
| 28 | $method->setAccessible(true); |
||
| 29 | |||
| 30 | return $method->getValue($this->target); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 |