Skip to content

Commit a3e235d

Browse files
committed
Simplify and clean up AliasGroupListTest assertions
1 parent 4a73598 commit a3e235d

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

tests/unit/Term/AliasGroupListTest.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testGivenTwoGroups_listContainsThem() {
4848

4949
$list = new AliasGroupList( $array );
5050

51-
$this->assertEquals( $array, iterator_to_array( $list ) );
51+
$this->assertSame( $array, iterator_to_array( $list ) );
5252
}
5353

5454
public function testGivenGroupsWithTheSameLanguage_onlyTheLastOnesAreRetained() {
@@ -85,7 +85,7 @@ public function testCanIterateOverList() {
8585
*/
8686
foreach ( $list as $key => $aliasGroup ) {
8787
$this->assertEquals( $group, $aliasGroup );
88-
$this->assertEquals( $aliasGroup->getLanguageCode(), $key );
88+
$this->assertSame( $aliasGroup->getLanguageCode(), $key );
8989
}
9090
}
9191

@@ -159,7 +159,7 @@ public function testGivenSetLanguage_removeByLanguageRemovesIt() {
159159

160160
$list->removeByLanguage( 'en' );
161161

162-
$this->assertEquals( new AliasGroupList(), $list );
162+
$this->assertTrue( $list->isEmpty() );
163163
}
164164

165165
/**
@@ -172,33 +172,24 @@ public function testGivenInvalidLanguageCode_removeByLanguageIsNoOp( $languageCo
172172
}
173173

174174
public function testGivenEmptyGroups_constructorRemovesThem() {
175-
$enGroup = new AliasGroup( 'en', [ 'foo' ] );
176-
177175
$list = new AliasGroupList( [
178176
new AliasGroup( 'de' ),
179-
$enGroup,
180-
new AliasGroup( 'en' ),
181-
new AliasGroup( 'nl' ),
182-
] );
183-
184-
$expectedList = new AliasGroupList( [
177+
new AliasGroup( 'en', [ 'foo' ] ),
185178
new AliasGroup( 'en' ),
186179
] );
187180

188-
$this->assertEquals( $expectedList, $list );
181+
$this->assertTrue( $list->isEmpty() );
189182
}
190183

191184
public function testGivenEmptyGroup_setGroupRemovesGroup() {
192185
$list = new AliasGroupList( [
193186
new AliasGroup( 'en', [ 'foo' ] ),
194187
] );
195188

196-
$expectedList = new AliasGroupList();
197-
198189
$list->setGroup( new AliasGroup( 'en' ) );
199190
$list->setGroup( new AliasGroup( 'de' ) );
200191

201-
$this->assertEquals( $expectedList, $list );
192+
$this->assertEquals( new AliasGroupList(), $list );
202193
}
203194

204195
public function testEmptyListEqualsEmptyList() {
@@ -333,7 +324,7 @@ public function testToArray() {
333324

334325
$list = new AliasGroupList( $array );
335326

336-
$this->assertEquals( $array, $list->toArray() );
327+
$this->assertSame( $array, $list->toArray() );
337328
}
338329

339330
public function testGivenEmptyList_getWithLanguagesReturnsEmptyList() {

0 commit comments

Comments
 (0)