🌚

怎样测试PHP的Private或Protected方法

Posted at — Jul 03, 2017
#编程 #测试 #PHP

利用闭包绑定:

1
2
3
4
5
6
7
$ctrlr = new UserController;

$tester = function () use ($uid) {
    $this->getUser($uid);
};
$runner = $tester->bindTo($ctrlr, $ctrlr);
$runner();