Skip to content

Commit 70eb1d7

Browse files
authored
patch: remove order dependency from anagram test (#873)
[no important files changed]
1 parent aa40d0b commit 70eb1d7

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Diff for: exercises/practice/anagram/AnagramTest.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function setUpBeforeClass(): void
1515
*/
1616
public function testNoMatches(): void
1717
{
18-
$this->assertEquals([], detectAnagrams('diaper', ['hello', 'world', 'zombies', 'pants']));
18+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('diaper', ['hello', 'world', 'zombies', 'pants'])));
1919
}
2020

2121
/**
@@ -24,9 +24,9 @@ public function testNoMatches(): void
2424
*/
2525
public function testDetectsTwoAnagrams(): void
2626
{
27-
$this->assertEquals(
27+
$this->assertEqualsCanonicalizing(
2828
['lemons', 'melons'],
29-
detectAnagrams('solemn', ['lemons', 'cherry', 'melons'])
29+
array_values(detectAnagrams('solemn', ['lemons', 'cherry', 'melons']))
3030
);
3131
}
3232

@@ -36,7 +36,7 @@ public function testDetectsTwoAnagrams(): void
3636
*/
3737
public function testDoesNotDetectAnagramSubsets(): void
3838
{
39-
$this->assertEquals([], detectAnagrams('good', ['dog', 'goody']));
39+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('good', ['dog', 'goody'])));
4040
}
4141

4242
/**
@@ -45,7 +45,7 @@ public function testDoesNotDetectAnagramSubsets(): void
4545
*/
4646
public function testDetectsAnagram(): void
4747
{
48-
$this->assertEquals(['inlets'], detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana']));
48+
$this->assertEqualsCanonicalizing(['inlets'], array_values(detectAnagrams('listen', ['enlists', 'google', 'inlets', 'banana'])));
4949
}
5050

5151
/**
@@ -54,9 +54,9 @@ public function testDetectsAnagram(): void
5454
*/
5555
public function testDetectsThreeAnagrams(): void
5656
{
57-
$this->assertEquals(
57+
$this->assertEqualsCanonicalizing(
5858
['gallery', 'regally', 'largely'],
59-
detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading'])
59+
array_values(detectAnagrams('allergy', ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']))
6060
);
6161
}
6262

@@ -66,7 +66,7 @@ public function testDetectsThreeAnagrams(): void
6666
*/
6767
public function testDetectsMultipleAnagramsWithDifferentCase(): void
6868
{
69-
$this->assertEquals(['Eons', 'ONES'], detectAnagrams('nose', ['Eons', 'ONES']));
69+
$this->assertEqualsCanonicalizing(['Eons', 'ONES'], array_values(detectAnagrams('nose', ['Eons', 'ONES'])));
7070
}
7171

7272
/**
@@ -75,7 +75,7 @@ public function testDetectsMultipleAnagramsWithDifferentCase(): void
7575
*/
7676
public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void
7777
{
78-
$this->assertEquals([], detectAnagrams('mass', ['last']));
78+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('mass', ['last'])));
7979
}
8080

8181
/**
@@ -84,7 +84,7 @@ public function testDoesNotDetectNonAnagramsWithIdenticalChecksum(): void
8484
*/
8585
public function testDetectsAnagramsCaseInsensitively(): void
8686
{
87-
$this->assertEquals(['Carthorse'], detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes']));
87+
$this->assertEqualsCanonicalizing(['Carthorse'], array_values(detectAnagrams('Orchestra', ['cashregister', 'Carthorse', 'radishes'])));
8888
}
8989

9090
/**
@@ -93,7 +93,7 @@ public function testDetectsAnagramsCaseInsensitively(): void
9393
*/
9494
public function testDetectsAnagramsUsingCaseInsensitiveSubject(): void
9595
{
96-
$this->assertEquals(['carthorse'], detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes']));
96+
$this->assertEqualsCanonicalizing(['carthorse'], array_values(detectAnagrams('Orchestra', ['cashregister', 'carthorse', 'radishes'])));
9797
}
9898

9999
/**
@@ -102,7 +102,7 @@ public function testDetectsAnagramsUsingCaseInsensitiveSubject(): void
102102
*/
103103
public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void
104104
{
105-
$this->assertEquals(['Carthorse'], detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes']));
105+
$this->assertEqualsCanonicalizing(['Carthorse'], array_values(detectAnagrams('orchestra', ['cashregister', 'Carthorse', 'radishes'])));
106106
}
107107

108108
/**
@@ -111,7 +111,7 @@ public function testDetectsAnagramsUsingCaseInsensitvePossibleMatches(): void
111111
*/
112112
public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void
113113
{
114-
$this->assertEquals([], detectAnagrams('go', ['goGoGO']));
114+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('go', ['goGoGO'])));
115115
}
116116

117117
/**
@@ -120,7 +120,7 @@ public function testDoesNotDetectAAnagramIfTheOriginalWordIsRepeated(): void
120120
*/
121121
public function testAnagramsMustUseAllLettersExactlyOnce(): void
122122
{
123-
$this->assertEquals([], detectAnagrams('tapper', ['patter']));
123+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('tapper', ['patter'])));
124124
}
125125

126126
/**
@@ -129,7 +129,7 @@ public function testAnagramsMustUseAllLettersExactlyOnce(): void
129129
*/
130130
public function testWordsAreNotAnagramsOfThemselves(): void
131131
{
132-
$this->assertEquals([], detectAnagrams('BANANA', ['BANANA']));
132+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['BANANA'])));
133133
}
134134

135135
/**
@@ -138,7 +138,7 @@ public function testWordsAreNotAnagramsOfThemselves(): void
138138
*/
139139
public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDifferent(): void
140140
{
141-
$this->assertEquals([], detectAnagrams('BANANA', ['Banana']));
141+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['Banana'])));
142142
}
143143

144144
/**
@@ -147,7 +147,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDi
147147
*/
148148
public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDifferent(): void
149149
{
150-
$this->assertEquals([], detectAnagrams('BANANA', ['banana']));
150+
$this->assertEqualsCanonicalizing([], array_values(detectAnagrams('BANANA', ['banana'])));
151151
}
152152

153153
/**
@@ -156,7 +156,7 @@ public function testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyD
156156
*/
157157
public function testWordsOtherThanThemselvesCanBeAnagrams(): void
158158
{
159-
$this->assertEquals(['Silent'], detectAnagrams('LISTEN', ['LISTEN', 'Silent']));
159+
$this->assertEqualsCanonicalizing(['Silent'], array_values(detectAnagrams('LISTEN', ['LISTEN', 'Silent'])));
160160
}
161161

162162
/**

0 commit comments

Comments
 (0)