diff --git a/src/Domain/Shoe.php b/src/Domain/Shoe.php new file mode 100644 index 0000000..7ed7cc1 --- /dev/null +++ b/src/Domain/Shoe.php @@ -0,0 +1,37 @@ +cards[] = new Card($rank, $suit); + } + } + } + } + + public function count(): int + { + return count($this->cards); + } + + public function draw(): Card + { + return array_shift($this->cards); + } + + public function shuffle(): void + { + shuffle($this->cards); + } +} \ No newline at end of file diff --git a/tests/Domain/ShoeTest.php b/tests/Domain/ShoeTest.php new file mode 100644 index 0000000..9e6b712 --- /dev/null +++ b/tests/Domain/ShoeTest.php @@ -0,0 +1,50 @@ +assertSame(52, $shoe->count()); + } + + public function testDrawReturnsACard(): void + { + $shoe = new Shoe(1); + $card = $shoe->draw(); + + $this->assertInstanceOf(Card::class, $card); + } + + public function testDrawReducesCardCount(): void + { + $shoe = new Shoe(1); + $shoe->draw(); + + $this->assertSame(51, $shoe->count()); + } + + public function testShuffleRandomizesCards(): void + { + $shoe1 = new Shoe(1); + $shoe2 = new Shoe(1); + $shoe2->shuffle(); + + $cards1 = []; + $cards2 = []; + + for ($i = 0; $i < 52; $i++) { + $cards1[] = $shoe1->draw()->rank(); + $cards2[] = $shoe2->draw()->rank(); + } + + $this->assertNotEquals($cards1, $cards2); + } +}