Example #1
0
 /**
  * Create cards array for tests
  *
  * @return Card[]
  */
 public static function getCardsArray() : array
 {
     $cardsArray = array();
     foreach (self::getCardsDataArray() as $cardData) {
         $figure = $cardData[0];
         $suit = $cardData[1] ?? null;
         $visible = $cardData[2] ?? null;
         if ($suit !== null) {
             $card = new Card($figure, $suit);
         } else {
             $card = new Card($figure);
         }
         if ($visible !== null) {
             $card->setVisible($visible);
         }
         $cardsArray[] = $card;
     }
     return $cardsArray;
 }
Example #2
0
 /**
  * Is card with $figure in collection
  *
  * @param string $figure
  * @return bool
  */
 public function hasCardWithFigure(string $figure) : bool
 {
     Card::checkFigureIsCorrect($figure);
     foreach ($this->cards as $card) {
         if ($card->getFigure() === $figure) {
             return true;
         }
     }
     return false;
 }
Example #3
0
 public function testCheckFigureIsCorrect()
 {
     foreach (FigureInterface::FIGURES as $figure) {
         Card::checkFigureIsCorrect($figure);
         $this->addToAssertionCount(1);
     }
     $expectedException = CardException::incorrectFigure('notExistedFigure');
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     Card::checkFigureIsCorrect('notExistedFigure');
 }