5.3.2になってPHPのReflectionMethodにsetAccessibleが実装されていた。
ということで、これでprivateメソッドのテストを簡単に実現することができます。
public function testGetMaxFile() { $this->object = TargetClass::getInstance(); $method = new ReflectionMethod("TargetClass", "targetMethod"); $method->setAccessible(true); $this->assertEquals('expected',$method->invoke($this->object,"arg")); }
0 件のコメント:
コメントを投稿