Tests: Replace some occurrences of assertEquals() with assertSame().

This ensures that not only the return values match the expected results, but also that their type is the same.

Props costdev, desrosj.
See #55654.

git-svn-id: https://develop.svn.wordpress.org/trunk@54402 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2022-10-07 01:02:07 +00:00
parent 8128f19599
commit 28fdf705dc
40 changed files with 119 additions and 128 deletions

View File

@@ -75,7 +75,7 @@ class Tests_Term extends WP_UnitTestCase {
)
);
// There are 5 posts, all Uncategorized.
$this->assertEquals( 1, $count );
$this->assertSame( '1', $count );
}
/**
@@ -86,14 +86,14 @@ class Tests_Term extends WP_UnitTestCase {
// Counts all terms (1 default category, 5 tags).
$count = wp_count_terms();
$this->assertEquals( 6, $count );
$this->assertSame( '6', $count );
// Counts only tags (5), with both current and legacy signature.
// Legacy usage should not trigger deprecated notice.
$count = wp_count_terms( array( 'taxonomy' => 'post_tag' ) );
$legacy_count = wp_count_terms( 'post_tag' );
$this->assertEquals( 5, $count );
$this->assertEquals( $count, $legacy_count );
$this->assertSame( '5', $count );
$this->assertSame( $count, $legacy_count );
}
/**
@@ -159,7 +159,7 @@ class Tests_Term extends WP_UnitTestCase {
$this->assertIsNumeric( $t );
$this->assertNotWPError( $t );
$this->assertGreaterThan( 0, $t );
$this->assertEquals( $initial_count + 1, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
$this->assertSame( (string) ( $initial_count + 1 ), wp_count_terms( array( 'taxonomy' => 'category' ) ) );
// Make sure the term exists.
$this->assertGreaterThan( 0, term_exists( $term ) );
@@ -169,7 +169,7 @@ class Tests_Term extends WP_UnitTestCase {
$this->assertTrue( wp_delete_category( $t ) );
$this->assertNull( term_exists( $term ) );
$this->assertNull( term_exists( $t ) );
$this->assertEquals( $initial_count, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
$this->assertSame( $initial_count, wp_count_terms( array( 'taxonomy' => 'category' ) ) );
}
/**