Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  * @dataProvider emptyAndFilledCardCollectionProvider
  */
 public function testCollectLast(CardCollection $cardCollection)
 {
     $count = $cardCollection->count();
     if ($count > 0) {
         $expectedCard = $cardCollection->getLast();
         $this->assertTrue($cardCollection->has($expectedCard));
         $this->assertArrayIsSequential($cardCollection->getAll());
         $collectedCard = $cardCollection->collectLast();
         $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::emptyCollection();
         $this->expectException(get_class($expectedException));
         $this->expectExceptionMessage($expectedException->getMessage());
         $cardCollection->collectLast();
     }
 }