diff --git a/exercises/practice/sublist/SublistTest.php b/exercises/practice/sublist/SublistTest.php index cac899b0c..a38c674ca 100644 --- a/exercises/practice/sublist/SublistTest.php +++ b/exercises/practice/sublist/SublistTest.php @@ -7,28 +7,22 @@ class SublistTest extends TestCase { - private Sublist $sublist; - public static function setUpBeforeClass(): void { require_once 'Sublist.php'; } - public function setUp(): void - { - $this->sublist = new Sublist(); - } - /** * uuid: 97319c93-ebc5-47ab-a022-02a1980e1d29 */ #[TestDox('Empty lists')] public function testEmptyLists(): void { + $sublist = new Sublist(); $listOne = []; $listTwo = []; - $this->assertEquals('EQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('EQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -37,10 +31,11 @@ public function testEmptyLists(): void #[TestDox('Empty list within non empty list')] public function testEmptyListWithinNonEmptyList(): void { + $sublist = new Sublist(); $listOne = []; $listTwo = [1, 2, 3]; - $this->assertEquals('SUBLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUBLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -49,10 +44,11 @@ public function testEmptyListWithinNonEmptyList(): void #[TestDox('Non empty list contains empty list')] public function testNonEmptyListContainsEmptyList(): void { + $sublist = new Sublist(); $listOne = [1, 2, 3]; $listTwo = []; - $this->assertEquals('SUPERLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUPERLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -61,10 +57,11 @@ public function testNonEmptyListContainsEmptyList(): void #[TestDox('List equals itself')] public function testListEqualsItself(): void { + $sublist = new Sublist(); $listOne = [1, 2, 3]; $listTwo = [1, 2, 3]; - $this->assertEquals('EQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('EQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -73,10 +70,11 @@ public function testListEqualsItself(): void #[TestDox('Different lists')] public function testDifferentLists(): void { + $sublist = new Sublist(); $listOne = [1, 2, 3]; $listTwo = [2, 3, 4]; - $this->assertEquals('UNEQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('UNEQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -85,10 +83,11 @@ public function testDifferentLists(): void #[TestDox('False start')] public function testFalseStart(): void { + $sublist = new Sublist(); $listOne = [1, 2, 5]; $listTwo = [0, 1, 2, 3, 1, 2, 5, 6]; - $this->assertEquals('SUBLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUBLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -97,10 +96,11 @@ public function testFalseStart(): void #[TestDox('Consecutive')] public function testConsecutive(): void { + $sublist = new Sublist(); $listOne = [1, 1, 2]; $listTwo = [0, 1, 1, 1, 2, 1, 2]; - $this->assertEquals('SUBLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUBLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -109,10 +109,11 @@ public function testConsecutive(): void #[TestDox('Sublist at start')] public function testSublistAtStart(): void { + $sublist = new Sublist(); $listOne = [0, 1, 2]; $listTwo = [0, 1, 2, 3, 4, 5]; - $this->assertEquals('SUBLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUBLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -121,10 +122,11 @@ public function testSublistAtStart(): void #[TestDox('Sublist in middle')] public function testSublistInMiddle(): void { + $sublist = new Sublist(); $listOne = [2, 3, 4]; $listTwo = [0, 1, 2, 3, 4, 5]; - $this->assertEquals('SUBLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUBLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -133,10 +135,11 @@ public function testSublistInMiddle(): void #[TestDox('Sublist at end')] public function testSublistAtEnd(): void { + $sublist = new Sublist(); $listOne = [3, 4, 5]; $listTwo = [0, 1, 2, 3, 4, 5]; - $this->assertEquals('SUBLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUBLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -145,10 +148,11 @@ public function testSublistAtEnd(): void #[TestDox('At start of superlist')] public function testAtStartOfSuperlist(): void { + $sublist = new Sublist(); $listOne = [0, 1, 2, 3, 4, 5]; $listTwo = [0, 1, 2]; - $this->assertEquals('SUPERLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUPERLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -157,10 +161,11 @@ public function testAtStartOfSuperlist(): void #[TestDox('In middle of superlist')] public function testInMiddleOfSuperlist(): void { + $sublist = new Sublist(); $listOne = [0, 1, 2, 3, 4, 5]; $listTwo = [2, 3]; - $this->assertEquals('SUPERLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUPERLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -169,10 +174,11 @@ public function testInMiddleOfSuperlist(): void #[TestDox('At end of superlist')] public function testAtEndOfSuperlist(): void { + $sublist = new Sublist(); $listOne = [0, 1, 2, 3, 4, 5]; $listTwo = [3, 4, 5]; - $this->assertEquals('SUPERLIST', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('SUPERLIST', $sublist->compare($listOne, $listTwo)); } /** @@ -181,10 +187,11 @@ public function testAtEndOfSuperlist(): void #[TestDox('First list missing element from second list')] public function testFirstListMissingElementFromSecondList(): void { + $sublist = new Sublist(); $listOne = [1, 3]; $listTwo = [1, 2, 3]; - $this->assertEquals('UNEQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('UNEQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -193,10 +200,11 @@ public function testFirstListMissingElementFromSecondList(): void #[TestDox('Second list missing element from first list')] public function testSecondListMissingElementFromFirstList(): void { + $sublist = new Sublist(); $listOne = [1, 2, 3]; $listTwo = [1, 3]; - $this->assertEquals('UNEQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('UNEQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -205,10 +213,11 @@ public function testSecondListMissingElementFromFirstList(): void #[TestDox('First list missing additional digits from second list')] public function testFirstListMissingAdditionalDigitsFromSecondList(): void { + $sublist = new Sublist(); $listOne = [1, 2]; $listTwo = [1, 22]; - $this->assertEquals('UNEQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('UNEQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -217,10 +226,11 @@ public function testFirstListMissingAdditionalDigitsFromSecondList(): void #[TestDox('Order matters to a list')] public function testOrderMattersToList(): void { + $sublist = new Sublist(); $listOne = [1, 2, 3]; $listTwo = [3, 2, 1]; - $this->assertEquals('UNEQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('UNEQUAL', $sublist->compare($listOne, $listTwo)); } /** @@ -229,9 +239,10 @@ public function testOrderMattersToList(): void #[TestDox('Same digits but different numbers')] public function testSameDigitsButDifferentNumbers(): void { + $sublist = new Sublist(); $listOne = [1, 0, 1]; $listTwo = [10, 1]; - $this->assertEquals('UNEQUAL', $this->sublist->compare($listOne, $listTwo)); + $this->assertEquals('UNEQUAL', $sublist->compare($listOne, $listTwo)); } } diff --git a/exercises/practice/twelve-days/.meta/config.json b/exercises/practice/twelve-days/.meta/config.json index d93afccc4..9d37434df 100644 --- a/exercises/practice/twelve-days/.meta/config.json +++ b/exercises/practice/twelve-days/.meta/config.json @@ -3,7 +3,8 @@ "MichaelBunker" ], "contributors": [ - "A-O-Emmanuel" + "A-O-Emmanuel", + "resu-xuniL" ], "files": { "solution": [ diff --git a/exercises/practice/twelve-days/TwelveDaysTest.php b/exercises/practice/twelve-days/TwelveDaysTest.php index 19325cd60..4cf2984cf 100644 --- a/exercises/practice/twelve-days/TwelveDaysTest.php +++ b/exercises/practice/twelve-days/TwelveDaysTest.php @@ -7,26 +7,20 @@ class TwelveDaysTest extends TestCase { - private TwelveDays $twelveDays; - public static function setUpBeforeClass(): void { require_once 'TwelveDays.php'; } - public function setUp(): void - { - $this->twelveDays = new TwelveDays(); - } - /** * uuid c0b5a5e6-c89d-49b1-a6b2-9f523bff33f7 */ #[TestDox('Verse -> First day a partridge in a pear tree')] public function testVerseFirstDayAPartridgeInAPearTree(): void { + $twelveDays = new TwelveDays(); $expected = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(1, 1)); + $this->assertEquals($expected, $twelveDays->recite(1, 1)); } /** @@ -35,10 +29,11 @@ public function testVerseFirstDayAPartridgeInAPearTree(): void #[TestDox('Verse -> Second day two turtle doves')] public function testVerseSecondDayTwoTurtleDoves(): void { + $twelveDays = new TwelveDays(); $expected = "On the second day of Christmas my true love gave to me: two Turtle Doves, " . "and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(2, 2)); + $this->assertEquals($expected, $twelveDays->recite(2, 2)); } /** @@ -47,10 +42,11 @@ public function testVerseSecondDayTwoTurtleDoves(): void #[TestDox('Verse -> Third day three french hens')] public function testVerseThirdDayThreeFrenchHens(): void { + $twelveDays = new TwelveDays(); $expected = "On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, " . "and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(3, 3)); + $this->assertEquals($expected, $twelveDays->recite(3, 3)); } /** @@ -59,10 +55,11 @@ public function testVerseThirdDayThreeFrenchHens(): void #[TestDox('Verse -> Fourth day four calling birds')] public function testVerseFourthDayFourCallingBirds(): void { + $twelveDays = new TwelveDays(); $expected = "On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, " . "two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(4, 4)); + $this->assertEquals($expected, $twelveDays->recite(4, 4)); } /** @@ -71,10 +68,11 @@ public function testVerseFourthDayFourCallingBirds(): void #[TestDox('Verse -> Fifth day five gold rings')] public function testVerseFifthDayFiveGoldRings(): void { + $twelveDays = new TwelveDays(); $expected = "On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, " . "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(5, 5)); + $this->assertEquals($expected, $twelveDays->recite(5, 5)); } /** @@ -83,10 +81,11 @@ public function testVerseFifthDayFiveGoldRings(): void #[TestDox('Verse -> Sixth day six geese-a-laying')] public function testVerseSixthDaySixGeeseALaying(): void { + $twelveDays = new TwelveDays(); $expected = "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, " . "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(6, 6)); + $this->assertEquals($expected, $twelveDays->recite(6, 6)); } /** @@ -95,11 +94,12 @@ public function testVerseSixthDaySixGeeseALaying(): void #[TestDox('Verse -> Seventh day seven swans-a-swimming')] public function testVerseSeventhDaySevenSwansASwimming(): void { + $twelveDays = new TwelveDays(); $expected = "On the seventh day of Christmas my true love gave to me: seven Swans-a-Swimming, " . "six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " . "and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(7, 7)); + $this->assertEquals($expected, $twelveDays->recite(7, 7)); } /** @@ -108,11 +108,12 @@ public function testVerseSeventhDaySevenSwansASwimming(): void #[TestDox('Verse -> Eighth day eight maids-a-milking')] public function testVerseEightDayEightMaidsAMilking(): void { + $twelveDays = new TwelveDays(); $expected = "On the eighth day of Christmas my true love gave to me: eight Maids-a-Milking, " . "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " . "two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(8, 8)); + $this->assertEquals($expected, $twelveDays->recite(8, 8)); } /** @@ -121,11 +122,12 @@ public function testVerseEightDayEightMaidsAMilking(): void #[TestDox('Verse -> Ninth day nine ladies dancing')] public function testVerseNinthDayNineLadiesDancing(): void { + $twelveDays = new TwelveDays(); $expected = "On the ninth day of Christmas my true love gave to me: nine Ladies Dancing, " . "eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " . "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(9, 9)); + $this->assertEquals($expected, $twelveDays->recite(9, 9)); } /** @@ -134,11 +136,12 @@ public function testVerseNinthDayNineLadiesDancing(): void #[TestDox('Verse -> Tenth day ten lords-a-leaping')] public function testVerseTenthDayTenLordsALeaping(): void { + $twelveDays = new TwelveDays(); $expected = "On the tenth day of Christmas my true love gave to me: ten Lords-a-Leaping, " . "nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, " . "five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(10, 10)); + $this->assertEquals($expected, $twelveDays->recite(10, 10)); } /** @@ -147,12 +150,13 @@ public function testVerseTenthDayTenLordsALeaping(): void #[TestDox('Verse -> Eleventh day eleven pipers piping')] public function testVerseEleventhDayElevenPipersPiping(): void { + $twelveDays = new TwelveDays(); $expected = "On the eleventh day of Christmas my true love gave to me: eleven Pipers Piping, " . "ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, " . "six Geese-a-Laying, five Gold Rings, four Calling Birds, " . "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(11, 11)); + $this->assertEquals($expected, $twelveDays->recite(11, 11)); } /** @@ -161,12 +165,13 @@ public function testVerseEleventhDayElevenPipersPiping(): void #[TestDox('Verse -> Twelfth day twelve drummers drumming')] public function testVerseTwelfthDayTwelveDrummersDrumming(): void { + $twelveDays = new TwelveDays(); $expected = "On the twelfth day of Christmas my true love gave to me: twelve Drummers Drumming, " . "eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " . "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " . "two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(12, 12)); + $this->assertEquals($expected, $twelveDays->recite(12, 12)); } /** @@ -175,13 +180,14 @@ public function testVerseTwelfthDayTwelveDrummersDrumming(): void #[TestDox('Lyrics -> Recites first three verses of the song')] public function testLyricsRecitesFirstThreeVersesOfSong(): void { + $twelveDays = new TwelveDays(); $expected = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree." . PHP_EOL . "On the second day of Christmas my true love gave to me: two Turtle Doves, " . "and a Partridge in a Pear Tree." . PHP_EOL . "On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, " . "and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(1, 3)); + $this->assertEquals($expected, $twelveDays->recite(1, 3)); } /** @@ -190,6 +196,7 @@ public function testLyricsRecitesFirstThreeVersesOfSong(): void #[TestDox('Lyrics -> Recites three verses from the middle of the song')] public function testLyricsRecitesThreeVersesFromMiddleOfSong(): void { + $twelveDays = new TwelveDays(); $expected = "On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, " . "two Turtle Doves, and a Partridge in a Pear Tree." . PHP_EOL . @@ -197,7 +204,7 @@ public function testLyricsRecitesThreeVersesFromMiddleOfSong(): void "three French Hens, two Turtle Doves, and a Partridge in a Pear Tree." . PHP_EOL . "On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, " . "four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(4, 6)); + $this->assertEquals($expected, $twelveDays->recite(4, 6)); } /** @@ -206,6 +213,7 @@ public function testLyricsRecitesThreeVersesFromMiddleOfSong(): void #[TestDox('Lyrics -> Recites the whole song')] public function testLyricsRecitesTheWholeSong(): void { + $twelveDays = new TwelveDays(); $expected = "On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree." . PHP_EOL . "On the second day of Christmas my true love gave to me: two Turtle Doves, " . @@ -238,6 +246,6 @@ public function testLyricsRecitesTheWholeSong(): void "eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " . "seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " . "two Turtle Doves, and a Partridge in a Pear Tree."; - $this->assertEquals($expected, $this->twelveDays->recite(1, 12)); + $this->assertEquals($expected, $twelveDays->recite(1, 12)); } } diff --git a/exercises/practice/yacht/.meta/config.json b/exercises/practice/yacht/.meta/config.json index 62dd3af9d..3572c78f0 100644 --- a/exercises/practice/yacht/.meta/config.json +++ b/exercises/practice/yacht/.meta/config.json @@ -2,6 +2,9 @@ "authors": [ "MichaelBunker" ], + "contributors": [ + "resu-xuniL" + ], "files": { "solution": [ "Yacht.php" diff --git a/exercises/practice/yacht/YachtTest.php b/exercises/practice/yacht/YachtTest.php index 9d37f049c..a8f036155 100644 --- a/exercises/practice/yacht/YachtTest.php +++ b/exercises/practice/yacht/YachtTest.php @@ -7,25 +7,19 @@ class YachtTest extends TestCase { - private Yacht $yacht; - public static function setUpBeforeClass(): void { require_once 'Yacht.php'; } - public function setUp(): void - { - $this->yacht = new Yacht(); - } - /** * uuid 3060e4a5-4063-4deb-a380-a630b43a84b6 */ #[TestDox('Yacht')] public function testScoreYacht(): void { - $this->assertEquals(50, $this->yacht->score([5, 5, 5, 5, 5], 'yacht')); + $yacht = new Yacht(); + $this->assertEquals(50, $yacht->score([5, 5, 5, 5, 5], 'yacht')); } /** @@ -34,7 +28,8 @@ public function testScoreYacht(): void #[TestDox('Not Yacht')] public function testScoreNotYacht(): void { - $this->assertEquals(0, $this->yacht->score([1, 3, 3, 2, 5], 'yacht')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([1, 3, 3, 2, 5], 'yacht')); } /** @@ -43,7 +38,8 @@ public function testScoreNotYacht(): void #[TestDox('Ones')] public function testScoreOnes(): void { - $this->assertEquals(3, $this->yacht->score([1, 1, 1, 3, 5], 'ones')); + $yacht = new Yacht(); + $this->assertEquals(3, $yacht->score([1, 1, 1, 3, 5], 'ones')); } /** @@ -52,7 +48,8 @@ public function testScoreOnes(): void #[TestDox('Ones, out of order')] public function testScoreOnesOutOfOrders(): void { - $this->assertEquals(3, $this->yacht->score([3, 1, 1, 5, 1], 'ones')); + $yacht = new Yacht(); + $this->assertEquals(3, $yacht->score([3, 1, 1, 5, 1], 'ones')); } /** @@ -61,7 +58,8 @@ public function testScoreOnesOutOfOrders(): void #[TestDox('No ones')] public function testScoreNoOnes(): void { - $this->assertEquals(0, $this->yacht->score([4, 3, 6, 5, 5], 'ones')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([4, 3, 6, 5, 5], 'ones')); } /** @@ -70,7 +68,8 @@ public function testScoreNoOnes(): void #[TestDox('Twos')] public function testScoreTwos(): void { - $this->assertEquals(2, $this->yacht->score([2, 3, 4, 5, 6], 'twos')); + $yacht = new Yacht(); + $this->assertEquals(2, $yacht->score([2, 3, 4, 5, 6], 'twos')); } /** @@ -79,7 +78,8 @@ public function testScoreTwos(): void #[TestDox('Fours')] public function testScoreFours(): void { - $this->assertEquals(8, $this->yacht->score([1, 4, 1, 4, 1], 'fours')); + $yacht = new Yacht(); + $this->assertEquals(8, $yacht->score([1, 4, 1, 4, 1], 'fours')); } /** @@ -88,7 +88,8 @@ public function testScoreFours(): void #[TestDox('Yacht counted as threes')] public function testScoreYachtAsThrees(): void { - $this->assertEquals(15, $this->yacht->score([3, 3, 3, 3, 3], 'threes')); + $yacht = new Yacht(); + $this->assertEquals(15, $yacht->score([3, 3, 3, 3, 3], 'threes')); } /** @@ -97,7 +98,8 @@ public function testScoreYachtAsThrees(): void #[TestDox('Yacht of 3s counted as fives')] public function testScoreYachtThreesCountedAsFives(): void { - $this->assertEquals(0, $this->yacht->score([3, 3, 3, 3, 3], 'fives')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([3, 3, 3, 3, 3], 'fives')); } /** @@ -106,7 +108,8 @@ public function testScoreYachtThreesCountedAsFives(): void #[TestDox('Fives')] public function testScoreFives(): void { - $this->assertEquals(10, $this->yacht->score([1, 5, 3, 5, 3], 'fives')); + $yacht = new Yacht(); + $this->assertEquals(10, $yacht->score([1, 5, 3, 5, 3], 'fives')); } /** @@ -115,7 +118,8 @@ public function testScoreFives(): void #[TestDox('Sixes')] public function testScoreSixes(): void { - $this->assertEquals(6, $this->yacht->score([2, 3, 4, 5, 6], 'sixes')); + $yacht = new Yacht(); + $this->assertEquals(6, $yacht->score([2, 3, 4, 5, 6], 'sixes')); } /** @@ -124,7 +128,8 @@ public function testScoreSixes(): void #[TestDox('Full house two small, three big')] public function testScoreFullHouseThreeLargeNumbers(): void { - $this->assertEquals(16, $this->yacht->score([2, 2, 4, 4, 4], 'full house')); + $yacht = new Yacht(); + $this->assertEquals(16, $yacht->score([2, 2, 4, 4, 4], 'full house')); } /** @@ -133,7 +138,8 @@ public function testScoreFullHouseThreeLargeNumbers(): void #[TestDox('Full house three small, two big')] public function testScoreFullHouseThreeSmallNumbers(): void { - $this->assertEquals(19, $this->yacht->score([5, 3, 3, 5, 3], 'full house')); + $yacht = new Yacht(); + $this->assertEquals(19, $yacht->score([5, 3, 3, 5, 3], 'full house')); } /** @@ -142,7 +148,8 @@ public function testScoreFullHouseThreeSmallNumbers(): void #[TestDox('Two pair is not a full house')] public function testScoreTwoPairNotFullHouse(): void { - $this->assertEquals(0, $this->yacht->score([2, 2, 4, 4, 5], 'full house')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([2, 2, 4, 4, 5], 'full house')); } /** @@ -151,7 +158,8 @@ public function testScoreTwoPairNotFullHouse(): void #[TestDox('Four of a kind is not a full house')] public function testScoreFourOfAKindNotFullHouse(): void { - $this->assertEquals(0, $this->yacht->score([1, 4, 4, 4, 4], 'full house')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([1, 4, 4, 4, 4], 'full house')); } /** @@ -160,7 +168,8 @@ public function testScoreFourOfAKindNotFullHouse(): void #[TestDox('Yacht is not a full house')] public function testScoreYachtNotFullHouse(): void { - $this->assertEquals(0, $this->yacht->score([2, 2, 2, 2, 2], 'full house')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([2, 2, 2, 2, 2], 'full house')); } /** @@ -169,7 +178,8 @@ public function testScoreYachtNotFullHouse(): void #[TestDox('Four of a Kind')] public function testScoreFourOfAKind(): void { - $this->assertEquals(24, $this->yacht->score([6, 6, 4, 6, 6], 'four of a kind')); + $yacht = new Yacht(); + $this->assertEquals(24, $yacht->score([6, 6, 4, 6, 6], 'four of a kind')); } /** @@ -178,7 +188,8 @@ public function testScoreFourOfAKind(): void #[TestDox('Yacht can be scored as Four of a Kind')] public function testScoreYachtAsFourOfAKind(): void { - $this->assertEquals(12, $this->yacht->score([3, 3, 3, 3, 3], 'four of a kind')); + $yacht = new Yacht(); + $this->assertEquals(12, $yacht->score([3, 3, 3, 3, 3], 'four of a kind')); } /** @@ -187,7 +198,8 @@ public function testScoreYachtAsFourOfAKind(): void #[TestDox('Full house is not Four of a Kind')] public function testScoreFullHouseNotFourOfAKind(): void { - $this->assertEquals(0, $this->yacht->score([3, 3, 3, 5, 5], 'four of a kind')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([3, 3, 3, 5, 5], 'four of a kind')); } /** @@ -196,7 +208,8 @@ public function testScoreFullHouseNotFourOfAKind(): void #[TestDox('Little Straight')] public function testScoreLittleStraight(): void { - $this->assertEquals(30, $this->yacht->score([3, 5, 4, 1, 2], 'little straight')); + $yacht = new Yacht(); + $this->assertEquals(30, $yacht->score([3, 5, 4, 1, 2], 'little straight')); } /** @@ -205,7 +218,8 @@ public function testScoreLittleStraight(): void #[TestDox('Little Straight as Big Straight')] public function testScoreLittleStraightAsBigStraight(): void { - $this->assertEquals(0, $this->yacht->score([1, 2, 3, 4, 5], 'big straight')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([1, 2, 3, 4, 5], 'big straight')); } /** @@ -214,7 +228,8 @@ public function testScoreLittleStraightAsBigStraight(): void #[TestDox('Four in order but not a little straight')] public function testScoreFourInOrderNotStraight(): void { - $this->assertEquals(0, $this->yacht->score([1, 1, 2, 3, 4], 'little straight')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([1, 1, 2, 3, 4], 'little straight')); } /** @@ -223,7 +238,8 @@ public function testScoreFourInOrderNotStraight(): void #[TestDox('No pairs but not a little straight')] public function testScoreNoPairsNoLittleStraight(): void { - $this->assertEquals(0, $this->yacht->score([1, 2, 3, 4, 6], 'little straight')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([1, 2, 3, 4, 6], 'little straight')); } /** @@ -232,7 +248,8 @@ public function testScoreNoPairsNoLittleStraight(): void #[TestDox('Minimum is 1, maximum is 5, but not a little straight')] public function testScoreMinOneMaxFiveNotLittleStraight(): void { - $this->assertEquals(0, $this->yacht->score([1, 1, 3, 4, 5], 'little straight')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([1, 1, 3, 4, 5], 'little straight')); } /** @@ -241,7 +258,8 @@ public function testScoreMinOneMaxFiveNotLittleStraight(): void #[TestDox('Big Straight')] public function testScoreBigStraight(): void { - $this->assertEquals(30, $this->yacht->score([4, 6, 2, 5, 3], 'big straight')); + $yacht = new Yacht(); + $this->assertEquals(30, $yacht->score([4, 6, 2, 5, 3], 'big straight')); } /** @@ -250,7 +268,8 @@ public function testScoreBigStraight(): void #[TestDox('Big Straight as little straight')] public function testScoreBigStraightAsLittleStraight(): void { - $this->assertEquals(0, $this->yacht->score([6, 5, 4, 3, 2], 'little straight')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([6, 5, 4, 3, 2], 'little straight')); } /** @@ -259,7 +278,8 @@ public function testScoreBigStraightAsLittleStraight(): void #[TestDox('No pairs but not a big straight')] public function testScoreNoPairsNoBigStraight(): void { - $this->assertEquals(0, $this->yacht->score([6, 5, 4, 3, 1], 'big straight')); + $yacht = new Yacht(); + $this->assertEquals(0, $yacht->score([6, 5, 4, 3, 1], 'big straight')); } /** @@ -268,7 +288,8 @@ public function testScoreNoPairsNoBigStraight(): void #[TestDox('Choice')] public function testScoreChoice(): void { - $this->assertEquals(23, $this->yacht->score([3, 3, 5, 6, 6], 'choice')); + $yacht = new Yacht(); + $this->assertEquals(23, $yacht->score([3, 3, 5, 6, 6], 'choice')); } /** @@ -277,6 +298,7 @@ public function testScoreChoice(): void #[TestDox('Yacht as choice')] public function testScoreYachtAsChoice(): void { - $this->assertEquals(10, $this->yacht->score([2, 2, 2, 2, 2], 'choice')); + $yacht = new Yacht(); + $this->assertEquals(10, $yacht->score([2, 2, 2, 2, 2], 'choice')); } } diff --git a/exercises/practice/zebra-puzzle/.meta/config.json b/exercises/practice/zebra-puzzle/.meta/config.json index 464551f31..e5f1e10a7 100644 --- a/exercises/practice/zebra-puzzle/.meta/config.json +++ b/exercises/practice/zebra-puzzle/.meta/config.json @@ -2,6 +2,9 @@ "authors": [ "tomasnorre" ], + "contributors": [ + "resu-xuniL" + ], "files": { "solution": [ "ZebraPuzzle.php" diff --git a/exercises/practice/zebra-puzzle/ZebraPuzzleTest.php b/exercises/practice/zebra-puzzle/ZebraPuzzleTest.php index 1a41fb4fd..e134b37e0 100644 --- a/exercises/practice/zebra-puzzle/ZebraPuzzleTest.php +++ b/exercises/practice/zebra-puzzle/ZebraPuzzleTest.php @@ -7,25 +7,19 @@ class ZebraPuzzleTest extends TestCase { - private ZebraPuzzle $zebraPuzzle; - public static function setUpBeforeClass(): void { require_once 'ZebraPuzzle.php'; } - public function setUp(): void - { - $this->zebraPuzzle = new ZebraPuzzle(); - } - /** * uuid: 16efb4e4-8ad7-4d5e-ba96-e5537b66fd42 */ #[TestDox('Resident who drinks water')] public function testResidentWhoDrinksWater(): void { - $this->assertEquals('Norwegian', $this->zebraPuzzle->waterDrinker()); + $zebraPuzzle = new ZebraPuzzle(); + $this->assertEquals('Norwegian', $zebraPuzzle->waterDrinker()); } /** @@ -34,6 +28,7 @@ public function testResidentWhoDrinksWater(): void #[TestDox('Resident who owns zebra')] public function testResidentWhoOwnsZebra(): void { - $this->assertEquals('Japanese', $this->zebraPuzzle->zebraOwner()); + $zebraPuzzle = new ZebraPuzzle(); + $this->assertEquals('Japanese', $zebraPuzzle->zebraOwner()); } }