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); }
/** * 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); } }