Exemple #1
0
 public function testCheckSuitIsCorrect()
 {
     foreach (SuitInterface::SUITS as $suit) {
         Card::checkSuitIsCorrect($suit);
         $this->addToAssertionCount(1);
     }
     $expectedException = CardException::incorrectSuit('notExistedSuit');
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     Card::checkSuitIsCorrect('notExistedSuit');
 }
 public function testHasCardWithSuit()
 {
     $cardCollection = new CardCollection();
     foreach (SuitInterface::SUITS as $suit) {
         $this->assertFalse($cardCollection->hasCardWithSuit($suit));
     }
     $addedCard = TestDataProvider::getCard2();
     $cardCollection->append($addedCard);
     foreach (SuitInterface::SUITS as $suit) {
         if ($addedCard->getSuit() === $suit) {
             $this->assertTrue($cardCollection->hasCardWithSuit($suit));
         } else {
             $this->assertFalse($cardCollection->hasCardWithSuit($suit));
         }
     }
     $expectedException = CardException::incorrectSuit('notExistedSuit');
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     $cardCollection->hasCardWithSuit('notExistedSuit');
 }
Exemple #3
0
 /**
  * Check if suit is correct
  *
  * @param string $suit
  * @throws CardException
  */
 public static function checkSuitIsCorrect(string $suit)
 {
     if (false === in_array($suit, SuitInterface::SUITS)) {
         throw CardException::incorrectSuit($suit);
     }
 }