【发布时间】:2012-07-02 08:09:27
【问题描述】:
class Footer
{
private $_isEnabled;
public function __construct(){
$this->_isEnabled = true;
}
public function disable(){
$this->_isEnabled = false;
}
}
当我在将_isEanabled 设置为false 后为禁用函数编写单元测试时,我想断言它是否为false。
但是我怎样才能访问$_isEnabled?
这是我的测试功能:
public function testDisable(){
$footer = new Footer();
$footer->disable();
$this->assertFalse($footer->_isEnable);
}
【问题讨论】:
-
我认为这个问题应该重新打开,在接受的答案的 cmets 中有一个链接,描述了如何通过反射来做到这一点,它可以变成一个真正的答案,而且重复的问题也不要'似乎不再存在了
标签: php unit-testing reflection phpunit