0
我正在学习如何执行我的一些php代码的适当单元测试/测试用例。我有一个简单的功能atMaxLivesAllowed()
,我正在测试atMaxLivesAllowedTest()
下面。但我不知道如何将值传递给getLivesLeftCount()
以与max_lives_limit
进行比较。我怎样才能正确地做到这一点?任何想法什么其他测试可以执行该功能atMaxLivesAllowed()
?PHPUnit测试 - 单元测试的基本功能
public function getLivesCount(){
$lives = new Life();
$lives->player = $this->id;
$lives->lives_left = '1';
$lives->lives_used = '0';
return $player->count();
}
public function atMaxLivesAllowed(){
return $this->getLivesLeftCount() >= $this->max_lives_limit;
}
/*
* Tests the expected behavior of atMaxLivesAllowed
*
*/
public function atMaxLivesAllowedTest(){
$player->getLivesLeftCount(1);
$player->max_lives_limit=5;
$this->asertTrue($player->atMaxLivesAllowed());
}