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); }
/** * Check if player has $card * * @param Card $card * @throws PlayerException */ public function checkPlayerHasCard(Card $card) { if (false === $this->getCards()->has($card)) { throw PlayerException::playerDoesNotHaveCard($this, $card); } }