From 231698395443b7689e1e449d57521def595b0083 Mon Sep 17 00:00:00 2001 From: florentdevk Date: Mon, 22 Jun 2026 20:33:36 +0200 Subject: [PATCH 1/4] feat: add Shoe with deck generation --- src/Domain/Shoe.php | 27 +++++++++++++++++++++++++++ tests/Domain/ShoeTest.php | 16 ++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/Domain/Shoe.php create mode 100644 tests/Domain/ShoeTest.php diff --git a/src/Domain/Shoe.php b/src/Domain/Shoe.php new file mode 100644 index 0000000..9f034a8 --- /dev/null +++ b/src/Domain/Shoe.php @@ -0,0 +1,27 @@ +cards[] = new Card($rank, $suit); + } + } + } + } + + public function count(): int + { + return count($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..1552f82 --- /dev/null +++ b/tests/Domain/ShoeTest.php @@ -0,0 +1,16 @@ +assertSame(52, $shoe->count()); + } +} \ No newline at end of file From f015984609f03fcf2382217d8b1c390119c117f0 Mon Sep 17 00:00:00 2001 From: florentdevk Date: Mon, 22 Jun 2026 20:43:20 +0200 Subject: [PATCH 2/4] feat: Shoe can draw a card --- src/Domain/Shoe.php | 5 +++++ tests/Domain/ShoeTest.php | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Domain/Shoe.php b/src/Domain/Shoe.php index 9f034a8..b202653 100644 --- a/src/Domain/Shoe.php +++ b/src/Domain/Shoe.php @@ -24,4 +24,9 @@ public function count(): int { return count($this->cards); } + + public function draw(): Card + { + return array_shift($this->cards); + } } \ No newline at end of file diff --git a/tests/Domain/ShoeTest.php b/tests/Domain/ShoeTest.php index 1552f82..1ff625e 100644 --- a/tests/Domain/ShoeTest.php +++ b/tests/Domain/ShoeTest.php @@ -2,6 +2,7 @@ namespace App\Tests\Domain; +use App\Domain\Card; use App\Domain\Shoe; use PHPUnit\Framework\TestCase; @@ -13,4 +14,12 @@ public function testShoeWithOneDeckHas52Cards(): void $this->assertSame(52, $shoe->count()); } + + public function testDrawReturnsACard(): void + { + $shoe = new Shoe(1); + $card = $shoe->draw(); + + $this->assertInstanceOf(Card::class, $card); + } } \ No newline at end of file From 27f6941703187181ea17a84b91a05c39d9da8e62 Mon Sep 17 00:00:00 2001 From: florentdevk Date: Mon, 22 Jun 2026 20:44:13 +0200 Subject: [PATCH 3/4] test: drawing a card reduces shoe count --- tests/Domain/ShoeTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/Domain/ShoeTest.php b/tests/Domain/ShoeTest.php index 1ff625e..5b8ba33 100644 --- a/tests/Domain/ShoeTest.php +++ b/tests/Domain/ShoeTest.php @@ -22,4 +22,12 @@ public function testDrawReturnsACard(): void $this->assertInstanceOf(Card::class, $card); } -} \ No newline at end of file + + public function testDrawReducesCardCount(): void + { + $shoe = new Shoe(1); + $shoe->draw(); + + $this->assertSame(51, $shoe->count()); + } +} From 8036844654f95a60ded3cc6ea063f7f16e092f2e Mon Sep 17 00:00:00 2001 From: florentdevk Date: Mon, 22 Jun 2026 20:50:46 +0200 Subject: [PATCH 4/4] feat: Shoe can be shuffled --- src/Domain/Shoe.php | 5 +++++ tests/Domain/ShoeTest.php | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Domain/Shoe.php b/src/Domain/Shoe.php index b202653..7ed7cc1 100644 --- a/src/Domain/Shoe.php +++ b/src/Domain/Shoe.php @@ -29,4 +29,9 @@ 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 index 5b8ba33..9e6b712 100644 --- a/tests/Domain/ShoeTest.php +++ b/tests/Domain/ShoeTest.php @@ -30,4 +30,21 @@ public function testDrawReducesCardCount(): void $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); + } }