From a84d86f99abeeb913c0a693eaf1ac37a761d3922 Mon Sep 17 00:00:00 2001 From: Roland Oduberu Date: Tue, 22 Dec 2020 20:30:46 +0100 Subject: [PATCH] refactor - entity to VO --- src/Deck/Factories/Entity.php | 20 --------- src/Deck/Factories/VO.php | 20 +++++++++ src/Deck/{Entities => VOs}/Hand.php | 2 +- src/Evaluate.php | 4 +- src/Rules/AbstractRule.php | 10 ++--- src/Rules/Contracts/Rule.php | 10 ++--- src/Rules/Factories/{Entity.php => VO.php} | 12 +++--- src/Rules/Flush.php | 8 ++-- src/Rules/FourOfAKind.php | 8 ++-- src/Rules/FullHouse.php | 8 ++-- src/Rules/HighCard.php | 8 ++-- src/Rules/Pair.php | 8 ++-- src/Rules/RoyalFlush.php | 8 ++-- src/Rules/Straight.php | 8 ++-- src/Rules/StraightFlush.php | 18 ++++---- src/Rules/ThreeOfAKind.php | 8 ++-- src/Rules/TwoPair.php | 8 ++-- src/Rules/{Entities => VOs}/RuleResponse.php | 2 +- tests/Unit/Entities/Deck/HandTest.php | 30 ------------- .../Unit/Entities/Rules/RuleResponseTest.php | 43 ------------------- tests/Unit/Factories/Deck/EntityTest.php | 20 --------- tests/Unit/Factories/Deck/VOTest.php | 20 +++++++++ tests/Unit/Factories/Rules/EntityTest.php | 27 ------------ tests/Unit/Factories/Rules/VOTest.php | 27 ++++++++++++ tests/Unit/Rules/FlushTest.php | 6 +-- tests/Unit/Rules/FourOfAKindTest.php | 6 +-- tests/Unit/Rules/FullHouseTest.php | 6 +-- tests/Unit/Rules/HighCardTest.php | 6 +-- tests/Unit/Rules/PairTest.php | 6 +-- tests/Unit/Rules/RoyalFlushTest.php | 6 +-- tests/Unit/Rules/StraightFlushTest.php | 6 +-- tests/Unit/Rules/StraightTest.php | 6 +-- tests/Unit/Rules/ThreeOfAKindTest.php | 6 +-- tests/Unit/Rules/TwoPairTest.php | 6 +-- tests/Unit/VOs/Deck/HandTest.php | 30 +++++++++++++ tests/Unit/VOs/Rules/RuleResponseTest.php | 43 +++++++++++++++++++ 36 files changed, 235 insertions(+), 235 deletions(-) delete mode 100644 src/Deck/Factories/Entity.php create mode 100644 src/Deck/Factories/VO.php rename src/Deck/{Entities => VOs}/Hand.php (92%) rename src/Rules/Factories/{Entity.php => VO.php} (58%) rename src/Rules/{Entities => VOs}/RuleResponse.php (96%) delete mode 100644 tests/Unit/Entities/Deck/HandTest.php delete mode 100644 tests/Unit/Entities/Rules/RuleResponseTest.php delete mode 100644 tests/Unit/Factories/Deck/EntityTest.php create mode 100644 tests/Unit/Factories/Deck/VOTest.php delete mode 100644 tests/Unit/Factories/Rules/EntityTest.php create mode 100644 tests/Unit/Factories/Rules/VOTest.php create mode 100644 tests/Unit/VOs/Deck/HandTest.php create mode 100644 tests/Unit/VOs/Rules/RuleResponseTest.php diff --git a/src/Deck/Factories/Entity.php b/src/Deck/Factories/Entity.php deleted file mode 100644 index 5f2ae17..0000000 --- a/src/Deck/Factories/Entity.php +++ /dev/null @@ -1,20 +0,0 @@ -getSequence(); + $sequence = $handVO->getSequence(); $isFlush = $this->isFlush($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/FourOfAKind.php b/src/Rules/FourOfAKind.php index 84a64cb..4582131 100644 --- a/src/Rules/FourOfAKind.php +++ b/src/Rules/FourOfAKind.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class FourOfAKind extends AbstractRule { @@ -16,9 +16,9 @@ class FourOfAKind extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isFourAKind = $this->isFourOfAKind($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/FullHouse.php b/src/Rules/FullHouse.php index b09fbf0..1810de5 100644 --- a/src/Rules/FullHouse.php +++ b/src/Rules/FullHouse.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class FullHouse extends AbstractRule { @@ -16,9 +16,9 @@ class FullHouse extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isFullHouse = $this->isFullHouse($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/HighCard.php b/src/Rules/HighCard.php index 5372867..a5fc339 100644 --- a/src/Rules/HighCard.php +++ b/src/Rules/HighCard.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class HighCard extends AbstractRule { @@ -16,9 +16,9 @@ class HighCard extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isHighCard = $this->isHighCard($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/Pair.php b/src/Rules/Pair.php index 2fdf4db..47ea862 100644 --- a/src/Rules/Pair.php +++ b/src/Rules/Pair.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class Pair extends AbstractRule { @@ -16,9 +16,9 @@ class Pair extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isPair = $this->isPair($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/RoyalFlush.php b/src/Rules/RoyalFlush.php index 2174b65..0aaa475 100644 --- a/src/Rules/RoyalFlush.php +++ b/src/Rules/RoyalFlush.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class RoyalFlush extends AbstractRule { @@ -16,9 +16,9 @@ class RoyalFlush extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isRoyalSequence = $this->isRoyalFlushSequence($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/Straight.php b/src/Rules/Straight.php index 26f1ad8..a730f86 100644 --- a/src/Rules/Straight.php +++ b/src/Rules/Straight.php @@ -4,8 +4,8 @@ namespace Roliod\TexasHUPoker\Rules; use Roliod\TexasHUPoker\Deck\Rank; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class Straight extends AbstractRule { @@ -17,9 +17,9 @@ class Straight extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isStraight = $this->isStraight($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/StraightFlush.php b/src/Rules/StraightFlush.php index 06c5831..0af3d11 100644 --- a/src/Rules/StraightFlush.php +++ b/src/Rules/StraightFlush.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class StraightFlush extends AbstractRule { @@ -16,10 +16,10 @@ class StraightFlush extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); - $isStraightFlush = $this->isStraightFlush($handEntity); + $sequence = $handVO->getSequence(); + $isStraightFlush = $this->isStraightFlush($handVO); return $this->buildRuleResponse( $sequence, @@ -29,14 +29,14 @@ public function validate(HandEntity $handEntity): RuleResponseEntity } /** - * @param HandEntity $handEntity + * @param HandVO $handVO * * @return bool */ - private function isStraightFlush(HandEntity $handEntity): bool + private function isStraightFlush(HandVO $handVO): bool { - $flush = (new Flush())->validate($handEntity); - $straight = (new Straight())->validate($handEntity); + $flush = (new Flush())->validate($handVO); + $straight = (new Straight())->validate($handVO); return $flush->getMatches() && $straight->getMatches(); } diff --git a/src/Rules/ThreeOfAKind.php b/src/Rules/ThreeOfAKind.php index 575380d..a9fae41 100644 --- a/src/Rules/ThreeOfAKind.php +++ b/src/Rules/ThreeOfAKind.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class ThreeOfAKind extends AbstractRule { @@ -16,9 +16,9 @@ class ThreeOfAKind extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isThreeAKind = $this->isThreeOfAKind($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/TwoPair.php b/src/Rules/TwoPair.php index debd56f..94e3ab0 100644 --- a/src/Rules/TwoPair.php +++ b/src/Rules/TwoPair.php @@ -3,8 +3,8 @@ namespace Roliod\TexasHUPoker\Rules; -use Roliod\TexasHUPoker\Deck\Entities\Hand as HandEntity; -use Roliod\TexasHUPoker\Rules\Entities\RuleResponse as RuleResponseEntity; +use Roliod\TexasHUPoker\Deck\VOs\Hand as HandVO; +use Roliod\TexasHUPoker\Rules\VOs\RuleResponse as RuleResponseVO; class TwoPair extends AbstractRule { @@ -16,9 +16,9 @@ class TwoPair extends AbstractRule /** * {@inheritDoc} */ - public function validate(HandEntity $handEntity): RuleResponseEntity + public function validate(HandVO $handVO): RuleResponseVO { - $sequence = $handEntity->getSequence(); + $sequence = $handVO->getSequence(); $isTwoPair = $this->isTwoPair($sequence); return $this->buildRuleResponse( diff --git a/src/Rules/Entities/RuleResponse.php b/src/Rules/VOs/RuleResponse.php similarity index 96% rename from src/Rules/Entities/RuleResponse.php rename to src/Rules/VOs/RuleResponse.php index 9100c3d..40d5b96 100644 --- a/src/Rules/Entities/RuleResponse.php +++ b/src/Rules/VOs/RuleResponse.php @@ -1,7 +1,7 @@ getSequence()); - } - - public function testSetters(): void - { - $sequence = 'sequence'; - - $handEntity = new HandEntity('sequence1'); - $handEntity->setSequence($sequence); - - self::assertSame($sequence, $handEntity->getSequence()); - } -} diff --git a/tests/Unit/Entities/Rules/RuleResponseTest.php b/tests/Unit/Entities/Rules/RuleResponseTest.php deleted file mode 100644 index 4b9060a..0000000 --- a/tests/Unit/Entities/Rules/RuleResponseTest.php +++ /dev/null @@ -1,43 +0,0 @@ -getSequence()); - self::assertSame($rank, $ruleResponseEntity->getRank()); - self::assertSame($matches, $ruleResponseEntity->getMatches()); - } - - public function testSetters(): void - { - $rank = 2; - $sequence = 'hand'; - $matches = false; - - $ruleResponseEntity = new RuleResponseEntity('hand1', 3); - $ruleResponseEntity->setRank($rank); - $ruleResponseEntity->setSequence($sequence); - $ruleResponseEntity->setMatches($matches); - - self::assertSame($sequence, $ruleResponseEntity->getSequence()); - self::assertSame($rank, $ruleResponseEntity->getRank()); - self::assertSame($matches, $ruleResponseEntity->getMatches()); - } -} diff --git a/tests/Unit/Factories/Deck/EntityTest.php b/tests/Unit/Factories/Deck/EntityTest.php deleted file mode 100644 index bda19a8..0000000 --- a/tests/Unit/Factories/Deck/EntityTest.php +++ /dev/null @@ -1,20 +0,0 @@ -getSequence()); - } -} diff --git a/tests/Unit/Factories/Deck/VOTest.php b/tests/Unit/Factories/Deck/VOTest.php new file mode 100644 index 0000000..c01c846 --- /dev/null +++ b/tests/Unit/Factories/Deck/VOTest.php @@ -0,0 +1,20 @@ +getSequence()); + } +} diff --git a/tests/Unit/Factories/Rules/EntityTest.php b/tests/Unit/Factories/Rules/EntityTest.php deleted file mode 100644 index 00a9cfa..0000000 --- a/tests/Unit/Factories/Rules/EntityTest.php +++ /dev/null @@ -1,27 +0,0 @@ -getSequence()); - self::assertSame($rank, $ruleResponseEntity->getRank()); - self::assertSame($matches, $ruleResponseEntity->getMatches()); - } -} diff --git a/tests/Unit/Factories/Rules/VOTest.php b/tests/Unit/Factories/Rules/VOTest.php new file mode 100644 index 0000000..71fad6f --- /dev/null +++ b/tests/Unit/Factories/Rules/VOTest.php @@ -0,0 +1,27 @@ +getSequence()); + self::assertSame($rank, $ruleResponseVO->getRank()); + self::assertSame($matches, $ruleResponseVO->getMatches()); + } +} diff --git a/tests/Unit/Rules/FlushTest.php b/tests/Unit/Rules/FlushTest.php index c05c59a..baa217c 100644 --- a/tests/Unit/Rules/FlushTest.php +++ b/tests/Unit/Rules/FlushTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\Flush; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class FlushTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $flush = new Flush(); - $response = $flush->validate($handEntity); + $response = $flush->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/FourOfAKindTest.php b/tests/Unit/Rules/FourOfAKindTest.php index 6751e2c..25bc60a 100644 --- a/tests/Unit/Rules/FourOfAKindTest.php +++ b/tests/Unit/Rules/FourOfAKindTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\FourOfAKind; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class FourOfAKindTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $fourOfAKind = new FourOfAKind(); - $response = $fourOfAKind->validate($handEntity); + $response = $fourOfAKind->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/FullHouseTest.php b/tests/Unit/Rules/FullHouseTest.php index 95d8f27..5ce1bfe 100644 --- a/tests/Unit/Rules/FullHouseTest.php +++ b/tests/Unit/Rules/FullHouseTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\FullHouse; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class FullHouseTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $fullHouse = new FullHouse(); - $response = $fullHouse->validate($handEntity); + $response = $fullHouse->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/HighCardTest.php b/tests/Unit/Rules/HighCardTest.php index 01f163d..1106a39 100644 --- a/tests/Unit/Rules/HighCardTest.php +++ b/tests/Unit/Rules/HighCardTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\HighCard; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class HighCardTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $highCard = new HighCard(); - $response = $highCard->validate($handEntity); + $response = $highCard->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/PairTest.php b/tests/Unit/Rules/PairTest.php index 8dd3eca..d482cf7 100644 --- a/tests/Unit/Rules/PairTest.php +++ b/tests/Unit/Rules/PairTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\Pair; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class PairTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $pair = new Pair(); - $response = $pair->validate($handEntity); + $response = $pair->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/RoyalFlushTest.php b/tests/Unit/Rules/RoyalFlushTest.php index 02fef66..4759e4f 100644 --- a/tests/Unit/Rules/RoyalFlushTest.php +++ b/tests/Unit/Rules/RoyalFlushTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\RoyalFlush; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class RoyalFlushTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $royalFlush = new RoyalFlush(); - $response = $royalFlush->validate($handEntity); + $response = $royalFlush->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/StraightFlushTest.php b/tests/Unit/Rules/StraightFlushTest.php index 4699862..73895d9 100644 --- a/tests/Unit/Rules/StraightFlushTest.php +++ b/tests/Unit/Rules/StraightFlushTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\StraightFlush; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class StraightFlushTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $twoPair = new StraightFlush(); - $response = $twoPair->validate($handEntity); + $response = $twoPair->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/StraightTest.php b/tests/Unit/Rules/StraightTest.php index 10ea5ee..0fb5dfc 100644 --- a/tests/Unit/Rules/StraightTest.php +++ b/tests/Unit/Rules/StraightTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\Straight; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class StraightTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $straight = new Straight(); - $response = $straight->validate($handEntity); + $response = $straight->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/ThreeOfAKindTest.php b/tests/Unit/Rules/ThreeOfAKindTest.php index b0369f7..2abf197 100644 --- a/tests/Unit/Rules/ThreeOfAKindTest.php +++ b/tests/Unit/Rules/ThreeOfAKindTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\ThreeOfAKind; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class ThreeOfAKindTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $threeOfAKind = new ThreeOfAKind(); - $response = $threeOfAKind->validate($handEntity); + $response = $threeOfAKind->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/Rules/TwoPairTest.php b/tests/Unit/Rules/TwoPairTest.php index 048bbe8..369cddd 100644 --- a/tests/Unit/Rules/TwoPairTest.php +++ b/tests/Unit/Rules/TwoPairTest.php @@ -5,7 +5,7 @@ use Tests\BaseTestCase; use Roliod\TexasHUPoker\Rules\TwoPair; -use Roliod\TexasHUPoker\Deck\Factories\Entity as EntityFactory; +use Roliod\TexasHUPoker\Deck\Factories\VO as VOFactory; class TwoPairTest extends BaseTestCase { @@ -19,10 +19,10 @@ public function testItCanValidateHand( string $sequence, bool $matches ): void { - $handEntity = EntityFactory::buildHandEntity($sequence); + $handVO = VOFactory::buildHandVO($sequence); $twoPair = new TwoPair(); - $response = $twoPair->validate($handEntity); + $response = $twoPair->validate($handVO); self::assertSame($matches, $response->getMatches()); } diff --git a/tests/Unit/VOs/Deck/HandTest.php b/tests/Unit/VOs/Deck/HandTest.php new file mode 100644 index 0000000..dae6030 --- /dev/null +++ b/tests/Unit/VOs/Deck/HandTest.php @@ -0,0 +1,30 @@ +getSequence()); + } + + public function testSetters(): void + { + $sequence = 'sequence'; + + $handVO = new HandVO('sequence1'); + $handVO->setSequence($sequence); + + self::assertSame($sequence, $handVO->getSequence()); + } +} diff --git a/tests/Unit/VOs/Rules/RuleResponseTest.php b/tests/Unit/VOs/Rules/RuleResponseTest.php new file mode 100644 index 0000000..0ba5573 --- /dev/null +++ b/tests/Unit/VOs/Rules/RuleResponseTest.php @@ -0,0 +1,43 @@ +getSequence()); + self::assertSame($rank, $ruleResponseVO->getRank()); + self::assertSame($matches, $ruleResponseVO->getMatches()); + } + + public function testSetters(): void + { + $rank = 2; + $sequence = 'hand'; + $matches = false; + + $ruleResponseVO = new RuleResponseVO('hand1', 3); + $ruleResponseVO->setRank($rank); + $ruleResponseVO->setSequence($sequence); + $ruleResponseVO->setMatches($matches); + + self::assertSame($sequence, $ruleResponseVO->getSequence()); + self::assertSame($rank, $ruleResponseVO->getRank()); + self::assertSame($matches, $ruleResponseVO->getMatches()); + } +}