From 70eb1d7850ae70870dec445521340be474d19ce7 Mon Sep 17 00:00:00 2001 From: Tim Austin Date: Sat, 25 Jan 2025 05:55:50 -0600 Subject: [PATCH] patch: remove order dependency from anagram test (#873) [no important files changed] --- exercises/practice/anagram/AnagramTest.php | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/exercises/practice/anagram/AnagramTest.php b/exercises/practice/anagram/AnagramTest.php index 03a2f113..a4dff2c6 100644 --- a/exercises/practice/anagram/AnagramTest.php +++ b/exercises/practice/anagram/AnagramTest.php @@ -15,7 +15,7 @@ public static function setUpBeforeClass(): void */ public function testNoMatches(): void { - $this->assertEquals([], detectAnagrams('diaper', ['hello', 'world', 'zombies', 'pants'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('diaper', ['hello', 'world', 'zombies', 'pants']))); } /** @@ -24,9 +24,9 @@ public function testNoMatches(): void */ public function testDetectsTwoAnagrams(): void { - $this->assertEquals( + $this->assertEqualsCanonicalizing( ['lemons', 'melons'], - detectAnagrams('solemn', ['lemons', 'cherry', 'melons']) + array_values(detectAnagrams('solemn', ['lemons', 'cherry', 'melons'])) ); } @@ -36,7 +36,7 @@ public function testDetectsTwoAnagrams(): void */ public function testDoesNotDetectAnagramSubsets(): void { - $this->assertEquals([], detectAnagrams('good', ['dog', 'goody'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('good', ['dog', 'goody']))); } /** @@ -45,7 +45,7 @@ public function testDoesNotDetectAnagramSubsets(): void */ public function testDetectsAnagram(): void { - $this->assertEquals(['inlets'], detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana'])); + $this->assertEqualsCanonicalizing(['inlets'], array_values(detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana']))); } /** @@ -54,9 +54,9 @@ public function testDetectsAnagram(): void */ public function testDetectsThreeAnagrams(): void { - $this->assertEquals( + $this->assertEqualsCanonicalizing( ['gallery', 'regally', 'largely'], - detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']) + array_values(detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading'])) ); } @@ -66,7 +66,7 @@ public function testDetectsThreeAnagrams(): void */ public function testDetectsMultipleAnagramsWithDifferentCase(): void { - $this->assertEquals(['Eons', 'ONES'], detectAnagrams('nose', ['Eons', 'ONES'])); + $this->assertEqualsCanonicalizing(['Eons', 'ONES'], array_values(detectAnagrams('nose', ['Eons', 'ONES']))); } /** @@ -75,7 +75,7 @@ public function testDetectsMultipleAnagramsWithDifferentCase(): void */ public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void { - $this->assertEquals([], detectAnagrams('mass', ['last'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('mass', ['last']))); } /** @@ -84,7 +84,7 @@ public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void */ public function testDetectsAnagramsCaseInsensitively(): void { - $this->assertEquals(['Carthorse'], detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes'])); + $this->assertEqualsCanonicalizing(['Carthorse'], array_values(detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes']))); } /** @@ -93,7 +93,7 @@ public function testDetectsAnagramsCaseInsensitively(): void */ public function testDetectsAnagramsUsingCaseInsensitiveSubject(): void { - $this->assertEquals(['carthorse'], detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes'])); + $this->assertEqualsCanonicalizing(['carthorse'], array_values(detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes']))); } /** @@ -102,7 +102,7 @@ public function testDetectsAnagramsUsingCaseInsensitiveSubject(): void */ public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void { - $this->assertEquals(['Carthorse'], detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes'])); + $this->assertEqualsCanonicalizing(['Carthorse'], array_values(detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes']))); } /** @@ -111,7 +111,7 @@ public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void */ public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void { - $this->assertEquals([], detectAnagrams('go', ['goGoGO'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('go', ['goGoGO']))); } /** @@ -120,7 +120,7 @@ public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void */ public function testAnagramsMustUseAllLettersExactlyOnce(): void { - $this->assertEquals([], detectAnagrams('tapper', ['patter'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('tapper', ['patter']))); } /** @@ -129,7 +129,7 @@ public function testAnagramsMustUseAllLettersExactlyOnce(): void */ public function testWordsAreNotAnagramsOfThemselves(): void { - $this->assertEquals([], detectAnagrams('BANANA', ['BANANA'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['BANANA']))); } /** @@ -138,7 +138,7 @@ public function testWordsAreNotAnagramsOfThemselves(): void */ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDifferent(): void { - $this->assertEquals([], detectAnagrams('BANANA', ['Banana'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['Banana']))); } /** @@ -147,7 +147,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDi */ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDifferent(): void { - $this->assertEquals([], detectAnagrams('BANANA', ['banana'])); + $this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['banana']))); } /** @@ -156,7 +156,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyD */ public function testWordsOtherThanThemselvesCanBeAnagrams(): void { - $this->assertEquals(['Silent'], detectAnagrams('LISTEN', ['LISTEN', 'Silent'])); + $this->assertEqualsCanonicalizing(['Silent'], array_values(detectAnagrams('LISTEN', ['LISTEN', 'Silent']))); } /**