Skip to content

Commit 48dda32

Browse files
authored
Merge pull request #748 from wmde/assertSame
Update some assertEquals to more safe assertSame
2 parents 0683be3 + cf2baee commit 48dda32

6 files changed

Lines changed: 27 additions & 35 deletions

File tree

tests/unit/Entity/ItemTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@ public function testSetLabel( $languageCode, $labelText, $moarText = 'ohi there'
418418

419419
$entity->setLabel( $languageCode, $labelText );
420420

421-
$this->assertEquals( $labelText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
421+
$this->assertSame( $labelText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
422422

423423
$entity->setLabel( $languageCode, $moarText );
424424

425-
$this->assertEquals( $moarText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
425+
$this->assertSame( $moarText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
426426
}
427427

428428
public function descriptionProvider() {
@@ -444,11 +444,11 @@ public function testSetDescription( $languageCode, $description, $moarText = 'oh
444444

445445
$entity->setDescription( $languageCode, $description );
446446

447-
$this->assertEquals( $description, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
447+
$this->assertSame( $description, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
448448

449449
$entity->setDescription( $languageCode, $moarText );
450450

451-
$this->assertEquals( $moarText, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
451+
$this->assertSame( $moarText, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
452452
}
453453

454454
public function aliasesProvider() {
@@ -490,12 +490,8 @@ public function testSetAliases( array $aliasesLists ) {
490490

491491
foreach ( $aliasesLists as $langCode => $aliasesList ) {
492492
$expected = array_values( array_unique( array_pop( $aliasesList ) ) );
493-
asort( $aliasesList );
494-
495493
$actual = $entity->getFingerprint()->getAliasGroup( $langCode )->getAliases();
496-
asort( $actual );
497-
498-
$this->assertEquals( $expected, $actual );
494+
$this->assertSame( $expected, $actual );
499495
}
500496
}
501497

tests/unit/Entity/PropertyTest.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testConstructorWithAllParameters() {
4444
$this->assertInstanceOf( Property::class, $property );
4545
$this->assertEquals( new PropertyId( 'P42' ), $property->getId() );
4646
$this->assertEquals( new Fingerprint(), $property->getFingerprint() );
47-
$this->assertEquals( 'string', $property->getDataTypeId() );
47+
$this->assertSame( 'string', $property->getDataTypeId() );
4848
$this->assertEquals( new StatementList(), $property->getStatements() );
4949
}
5050

@@ -53,7 +53,7 @@ public function testConstructorWithMinimalParameters() {
5353
$this->assertInstanceOf( Property::class, $property );
5454
$this->assertNull( $property->getId() );
5555
$this->assertEquals( new Fingerprint(), $property->getFingerprint() );
56-
$this->assertEquals( '', $property->getDataTypeId() );
56+
$this->assertSame( '', $property->getDataTypeId() );
5757
$this->assertEquals( new StatementList(), $property->getStatements() );
5858
}
5959

@@ -67,15 +67,15 @@ public function testGivenInvalidType_ConstructorThrowsException() {
6767
public function testNewFromType() {
6868
$property = Property::newFromType( 'string' );
6969
$this->assertInstanceOf( Property::class, $property );
70-
$this->assertEquals( 'string', $property->getDataTypeId() );
70+
$this->assertSame( 'string', $property->getDataTypeId() );
7171
}
7272

7373
public function testSetAndGetDataTypeId() {
7474
$property = Property::newFromType( 'string' );
7575

7676
foreach ( [ 'string', 'foobar', 'nyan', 'string' ] as $typeId ) {
7777
$property->setDataTypeId( $typeId );
78-
$this->assertEquals( $typeId, $property->getDataTypeId() );
78+
$this->assertSame( $typeId, $property->getDataTypeId() );
7979
}
8080
}
8181

@@ -296,11 +296,11 @@ public function testSetLabel( $languageCode, $labelText, $moarText = 'ohi there'
296296

297297
$entity->setLabel( $languageCode, $labelText );
298298

299-
$this->assertEquals( $labelText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
299+
$this->assertSame( $labelText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
300300

301301
$entity->setLabel( $languageCode, $moarText );
302302

303-
$this->assertEquals( $moarText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
303+
$this->assertSame( $moarText, $entity->getFingerprint()->getLabel( $languageCode )->getText() );
304304
}
305305

306306
public function descriptionProvider() {
@@ -322,11 +322,11 @@ public function testSetDescription( $languageCode, $description, $moarText = 'oh
322322

323323
$entity->setDescription( $languageCode, $description );
324324

325-
$this->assertEquals( $description, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
325+
$this->assertSame( $description, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
326326

327327
$entity->setDescription( $languageCode, $moarText );
328328

329-
$this->assertEquals( $moarText, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
329+
$this->assertSame( $moarText, $entity->getFingerprint()->getDescription( $languageCode )->getText() );
330330
}
331331

332332
public function aliasesProvider() {
@@ -368,12 +368,8 @@ public function testSetAliases( array $aliasesLists ) {
368368

369369
foreach ( $aliasesLists as $langCode => $aliasesList ) {
370370
$expected = array_values( array_unique( array_pop( $aliasesList ) ) );
371-
asort( $aliasesList );
372-
373371
$actual = $entity->getFingerprint()->getAliasGroup( $langCode )->getAliases();
374-
asort( $actual );
375-
376-
$this->assertEquals( $expected, $actual );
372+
$this->assertSame( $expected, $actual );
377373
}
378374
}
379375

tests/unit/Term/AliasGroupFallbackTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public function testConstructorSetsValues() {
2222

2323
$group = new AliasGroupFallback( $language, $aliases, $actual, $source );
2424

25-
$this->assertEquals( $language, $group->getLanguageCode() );
26-
$this->assertEquals( $aliases, $group->getAliases() );
27-
$this->assertEquals( $actual, $group->getActualLanguageCode() );
28-
$this->assertEquals( $source, $group->getSourceLanguageCode() );
25+
$this->assertSame( $language, $group->getLanguageCode() );
26+
$this->assertSame( $aliases, $group->getAliases() );
27+
$this->assertSame( $actual, $group->getActualLanguageCode() );
28+
$this->assertSame( $source, $group->getSourceLanguageCode() );
2929
}
3030

3131
public function testConstructorWithNullForSource() {
@@ -36,7 +36,7 @@ public function testConstructorWithNullForSource() {
3636

3737
$group = new AliasGroupFallback( $language, $aliases, $actual, $source );
3838

39-
$this->assertEquals( $source, $group->getSourceLanguageCode() );
39+
$this->assertSame( $source, $group->getSourceLanguageCode() );
4040
}
4141

4242
/**

tests/unit/Term/AliasGroupTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function testConstructorSetsValues() {
2020

2121
$group = new AliasGroup( $language, $aliases );
2222

23-
$this->assertEquals( $language, $group->getLanguageCode() );
24-
$this->assertEquals( $aliases, $group->getAliases() );
23+
$this->assertSame( $language, $group->getLanguageCode() );
24+
$this->assertSame( $aliases, $group->getAliases() );
2525
}
2626

2727
public function testIsEmpty() {

tests/unit/Term/TermFallbackTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class TermFallbackTest extends \PHPUnit_Framework_TestCase {
1616

1717
public function testConstructorSetsFields() {
1818
$term = new TermFallback( 'foor', 'bar', 'fooa', 'foos' );
19-
$this->assertEquals( 'foor', $term->getLanguageCode() );
20-
$this->assertEquals( 'bar', $term->getText() );
21-
$this->assertEquals( 'fooa', $term->getActualLanguageCode() );
22-
$this->assertEquals( 'foos', $term->getSourceLanguageCode() );
19+
$this->assertSame( 'foor', $term->getLanguageCode() );
20+
$this->assertSame( 'bar', $term->getText() );
21+
$this->assertSame( 'fooa', $term->getActualLanguageCode() );
22+
$this->assertSame( 'foos', $term->getSourceLanguageCode() );
2323
}
2424

2525
public function testConstructorWithNullAsSource() {

tests/unit/Term/TermTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class TermTest extends \PHPUnit_Framework_TestCase {
1616

1717
public function testConstructorSetsFields() {
1818
$term = new Term( 'foo', 'bar' );
19-
$this->assertEquals( 'foo', $term->getLanguageCode() );
20-
$this->assertEquals( 'bar', $term->getText() );
19+
$this->assertSame( 'foo', $term->getLanguageCode() );
20+
$this->assertSame( 'bar', $term->getText() );
2121
}
2222

2323
/**

0 commit comments

Comments
 (0)