I am learning how to perform proper unit testing/test cases of some of my php code. I have a simple function atMaxLivesAllowed()
that I am testing atMaxLivesAllowedTest()
below. But I am not sure how to pass a value to getLivesLeftCount()
to compare to max_lives_limit
. How can I do this correctly? any ideas what other test can I perform for that function atMaxLivesAllowed()
?
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());
}