/** * Check if card is in collection * * @param Card $card * @throws CardCollectionException */ public function checkIsCardInCollection(Card $card) { if (false === $this->has($card)) { throw CardCollectionException::noCardInCollection($card); } }
/** * @dataProvider emptyAndFilledCardCollectionProvider */ public function testCollect(CardCollection $cardCollection) { $count = $cardCollection->count(); if ($count > 0) { $expectedCard = $cardCollection->getFirst(); $this->assertTrue($cardCollection->has($expectedCard)); $this->assertArrayIsSequential($cardCollection->getAll()); $collectedCard = $cardCollection->collect($expectedCard); $this->assertSame($expectedCard, $collectedCard); $this->assertFalse($cardCollection->has($expectedCard)); $this->assertArrayIsSequential($cardCollection->getAll()); $this->assertSame(--$count, $cardCollection->count()); } else { $expectedCard = TestDataProvider::getCard2(); $this->assertFalse($cardCollection->has($expectedCard)); $expectedException = CardCollectionException::noCardInCollection($expectedCard); $this->expectException(get_class($expectedException)); $this->expectExceptionMessage($expectedException->getMessage()); $cardCollection->collect($expectedCard); } }