コード例 #1
0
ファイル: PlayerTest.php プロジェクト: bnowak/card-game
 public function testCheckPlayerHasNotCard()
 {
     $player = new Player('player name');
     $card = TestDataProvider::getCard2();
     $player->checkPlayerHasNotCard($card);
     $this->addToAssertionCount(1);
     $player->getCards()->append($card);
     $expectedException = PlayerException::playerHasAlreadyCard($player, $card);
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     $player->checkPlayerHasNotCard($card);
 }
コード例 #2
0
ファイル: Player.php プロジェクト: bnowak/card-game
 /**
  * Check if player has not $card
  *
  * @param Card $card
  * @throws PlayerException
  */
 public function checkPlayerHasNotCard(Card $card)
 {
     if ($this->getCards()->has($card)) {
         throw PlayerException::playerHasAlreadyCard($this, $card);
     }
 }