public function testDraw_Functional() { $card1 = new IdCard(); $card1->setId(1); $card1->setRate(55); $card2 = new IdCard(); $card2->setId(2); $card2->setRate(45); $box = new LuckyBox(); $box->add($card1); $box->add($card2); for ($i = 0; $i < 3; $i++) { $result = $box->draw(); $this->assertTrue($result === $card1 || $result === $card2); } $this->assertFalse($box->isEmpty()); $box->clear(); $this->assertTrue($box->isEmpty()); $box->add($card1); $box->add($card2); $box->setConsumable(true); while (!$box->isEmpty()) { $result = $box->draw(); $this->assertTrue($result === $card1 || $result === $card2); } $box->clear(); $this->assertTrue($box->isEmpty()); $box->add($card1); $this->assertFalse($box->isEmpty()); $box->remove($card1); $this->assertTrue($box->isEmpty()); }