Example #1
0
 public function test_it_contains_an_hand()
 {
     $hand = new Hand(...StaticFixtures::three_of_a_kind());
     $score = new Score($hand, 10);
     $this->assertEquals($hand, $score->getHand());
     $this->assertEquals(10, $score->getScore());
 }
Example #2
0
 public function test_it_will_return_a_score_with_the_max_face_value_adjusted_with_the_hands_strength()
 {
     $hand = new Hand(...StaticFixtures::straight());
     $finder = $this->prophesize(StraightFinder::class);
     $finder->find($hand)->willReturn($hand);
     $matcher = new Straight($finder->reveal());
     $expectedScore = new Score($hand, (3 + 4 + 5 + 6 + 7) * Straight::MULTIPLIER);
     $this->assertEquals($expectedScore, $matcher->match($hand));
 }
Example #3
0
 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));
 }
Example #4
0
 /**
  * @return array
  */
 public function hands()
 {
     return [[new Hand(...StaticFixtures::one_pair()), new Hand(...StaticFixtures::three_of_a_kind_matching_pair()), new Score(new Hand(...StaticFixtures::one_pair()), (2 + 2) * OnePair::MULTIPLIER)], [new Hand(...StaticFixtures::three_of_a_kind()), new Hand(...StaticFixtures::three_of_a_kind_matching_pair()), new Score(new Hand(...StaticFixtures::three_of_a_kind()), (2 + 2) * OnePair::MULTIPLIER)], [new Hand(...StaticFixtures::getFlush()), null, null]];
 }
Example #5
0
 /**
  * @return array
  */
 public function hands()
 {
     return [[new Hand(...StaticFixtures::two_pairs()), new Hand(...StaticFixtures::two_pairs_first_pair()), new Hand(...StaticFixtures::two_pairs_second_pair()), new Score(new Hand(...StaticFixtures::two_pairs()), (2 + 2 + 4 + 4) * TwoPairs::MULTIPLIER)], [new Hand(...StaticFixtures::three_of_a_kind()), new Hand(...StaticFixtures::three_of_a_kind_matching_pair()), null, null]];
 }
Example #6
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]];
 }
Example #7
0
 /**
  * @return array
  */
 public function hands()
 {
     return [[new Hand(...StaticFixtures::one_pair()), 2, new Hand(...StaticFixtures::three_of_a_kind_matching_pair()), new Hand(...StaticFixtures::three_of_a_kind_matching_pair())], [new Hand(...StaticFixtures::three_of_a_kind()), 2, new Hand(...StaticFixtures::three_of_a_kind_matching_pair()), new Hand(...StaticFixtures::three_of_a_kind_matching_pair())], [new Hand(...StaticFixtures::three_of_a_kind()), 2, null, null]];
 }
Example #8
0
 public function test_it_contains_up_to_five_cards()
 {
     $hand = new Hand(...StaticFixtures::getFlush());
     $this->assertLessThanOrEqual(5, count($hand->getCards()));
 }
Example #9
0
 /**
  * @return array
  */
 public function hands()
 {
     return [[new Hand(...StaticFixtures::one_pair()), new Score(new Hand(...StaticFixtures::one_pair()), 6 * HighCard::MULTIPLIER)], [new Hand(...StaticFixtures::three_of_a_kind()), new Score(new Hand(...StaticFixtures::three_of_a_kind()), 10 * HighCard::MULTIPLIER)]];
 }
Example #10
0
 /**
  * @return array
  */
 public function hands()
 {
     return [[new Hand(...StaticFixtures::three_of_a_kind()), new Hand(...StaticFixtures::three_of_a_kind_actual_three()), new Score(new Hand(...StaticFixtures::three_of_a_kind()), (2 + 2 + 2) * ThreeOfAKind::MULTIPLIER)], [new Hand(...StaticFixtures::one_pair()), null, null]];
 }