feedtailor / mocking-method-invoker
用于模拟对象的任何方法调用者。
0.1.0
2014-08-05 01:33 UTC
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-09-24 07:32:20 UTC
README
用于模拟对象的任何方法调用者。
安装
将 feedtailor/mocking-method-invoker
添加到您的项目 composer.json 文件的依赖项中。
{ "require": { "feedtailor/mocking-method-invoker": "dev-master" } }
示例
use Feedtailor\Mocking\MethodInvoker; class ExampleClass { protected function add($a, $b) { return $a + $b; } } $obj = new ExampleClass(); $result = MethodInvoker::create($obj)->invoke("getFoo", array(40, 2)) // got 42.
方法
$invoker = new MethodInvoker($obj);
$invoker = MethodInvoker::create($obj);
创建一个新的 MethodInvoker 实例。
$invoker->invoke($name, $args);
使用 $args
数组参数调用 $name
方法。
许可证
MIT 许可证下授权。