Beispiel #1
0
 public function testCheckPlayerHasCard()
 {
     $player = new Player('player name');
     $card = TestDataProvider::getCard2();
     $player->getCards()->append($card);
     $player->checkPlayerHasCard($card);
     $this->addToAssertionCount(1);
     $player->getCards()->clear();
     $expectedException = PlayerException::playerDoesNotHaveCard($player, $card);
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     $player->checkPlayerHasCard($card);
 }
 public function testHasCardWithFigure()
 {
     $cardCollection = new CardCollection();
     foreach (FigureInterface::FIGURES as $figure) {
         $this->assertFalse($cardCollection->hasCardWithFigure($figure));
     }
     $addedCard = TestDataProvider::getCard2();
     $cardCollection->append($addedCard);
     foreach (FigureInterface::FIGURES as $figure) {
         if ($addedCard->getFigure() === $figure) {
             $this->assertTrue($cardCollection->hasCardWithFigure($figure));
         } else {
             $this->assertFalse($cardCollection->hasCardWithFigure($figure));
         }
     }
     $expectedException = CardException::incorrectFigure('notExistedFigure');
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     $cardCollection->hasCardWithFigure('notExistedFigure');
 }
Beispiel #3
0
 public function testCheckEveryPlayersHasSituatedCards()
 {
     $player1 = TestDataProvider::getPlayer1();
     $player2 = TestDataProvider::getPlayer2();
     $card2 = TestDataProvider::getCard2();
     $card3 = TestDataProvider::getCard3();
     $gameTable = new GameTable(array($player1, $player2));
     $gameTable->getPlayerCards($player1)->append($card2);
     $gameTable->getPlayerCards($player2)->append($card3);
     $gameTable->checkEveryPlayersHasSituatedCards();
     $this->addToAssertionCount(1);
     $gameTable->getPlayerCards($player1)->clear();
     $expectedException = GameTableException::notAllPlayersPlacedCards();
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     $gameTable->checkEveryPlayersHasSituatedCards();
 }