コード例 #1
0
 /**
  * @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);
     }
 }