/**
  * @dataProvider hands
  *
  * @param HandInterface $hand
  * @param $searchedHand
  * @param $expectedHand
  */
 public function test_it_will_return_an_hand_that_matches_the_search_null_otherwise(HandInterface $hand, $howManyCards, $searchedHand, $expectedHand)
 {
     $handSearch = $this->prophesize(HandSearch::class);
     $handSearch->search(Argument::cetera())->willReturn(new Hand(...[]));
     $handSearch->search(new Card(2, Suit::spades()), Argument::cetera())->willReturn($searchedHand);
     $twoOfAKindFinder = new EqualityFinder($handSearch->reveal(), $howManyCards);
     $actualHand = $twoOfAKindFinder->find($hand);
     $this->assertEquals($expectedHand, $actualHand);
 }
 public function test_it_will_return_an_hand_that_matches_the_search_null_otherwise()
 {
     $handSearch = $this->prophesize(HandSearch::class);
     $handSearch->search(Argument::cetera())->willReturn(new Hand(...[]));
     $hand = new Hand(...StaticFixtures::straight());
     $handSearch->search(Argument::which('getFaceValue', 3), Argument::cetera())->willReturn(new Hand(new Card(3, Suit::spades())))->shouldBeCalled();
     $handSearch->search(Argument::which('getFaceValue', 4), Argument::cetera())->willReturn(new Hand(new Card(4, Suit::flowers())))->shouldBeCalled();
     $handSearch->search(Argument::which('getFaceValue', 5), Argument::cetera())->willReturn(new Hand(new Card(5, Suit::spades())))->shouldBeCalled();
     $handSearch->search(Argument::which('getFaceValue', 6), Argument::cetera())->willReturn(new Hand(new Card(6, Suit::spades())))->shouldBeCalled();
     $handSearch->search(Argument::which('getFaceValue', 7), Argument::cetera())->willReturn(new Hand(new Card(7, Suit::spades())))->shouldBeCalled();
     $handSearch->search(Argument::any(), Argument::cetera())->willReturn(null);
     $finder = new StraightFinder($handSearch->reveal());
     $this->assertEquals($hand, $finder->find($hand));
 }
Exemple #3
0
 public function test_should_have_a_valid_suit()
 {
     $card = new Card(2, Suit::spades());
     $this->assertInstanceOf(Suit::class, $card->getSuit());
 }
Exemple #4
0
 /**
  * @return array
  */
 public function hands()
 {
     return [[new Card(2, Suit::spades()), new Hand(...StaticFixtures::one_pair()), new Hand(...StaticFixtures::two_pairs_first_pair())], [new Card(2, Suit::spades()), new Hand(...StaticFixtures::three_of_a_kind()), new Hand(...StaticFixtures::three_of_a_kind_actual_three())], [new Card(9, Suit::spades()), new Hand(...StaticFixtures::three_of_a_kind()), null]];
 }
Exemple #5
0
 /**
  * @return array
  */
 public static function getFlush()
 {
     return [new Card(2, Suit::spades()), new Card(3, Suit::spades()), new Card(4, Suit::spades()), new Card(5, Suit::spades()), new Card(6, Suit::spades())];
 }
 public static function three_of_a_kind_matching_pair()
 {
     return [new Card(2, Suit::spades()), new Card(2, Suit::flowers())];
 }
Exemple #7
0
 public static function straight_actual_straight()
 {
     return [new Card(3, Suit::spades()), new Card(4, Suit::flowers()), new Card(5, Suit::spades()), new Card(6, Suit::spades()), new Card(7, Suit::spades())];
 }
Exemple #8
0
 public static function two_pairs_second_pair()
 {
     return [new Card(4, Suit::spades()), new Card(4, Suit::flowers())];
 }