Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.

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

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-09-02 00:35:36 +00:00
parent ba7c6a2d5f
commit 164b22cf6a
426 changed files with 7959 additions and 7949 deletions

View File

@@ -78,7 +78,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2008-12-10 13:06:27',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_year_expecting_noresults() {
@@ -104,7 +104,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2007-09-24 07:17:23',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_m_with_year_expecting_noresults() {
@@ -129,7 +129,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:01',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_m_with_yearmonth_expecting_noresults() {
@@ -154,7 +154,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:01',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_m_with_yearmonthday_expecting_noresults() {
@@ -179,7 +179,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:01',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_m_with_yearmonthdayhour_expecting_noresults() {
@@ -207,7 +207,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:01',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
/**
@@ -237,7 +237,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:01',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
/**
@@ -267,7 +267,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:00',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
/**
@@ -284,7 +284,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-04-20 10:13:00',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
/**
@@ -316,7 +316,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2025-05-20 10:13:01',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_monthnum_expecting_noresults() {
@@ -342,7 +342,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2012-06-13 14:03:34',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_w_as_in_week_expecting_noresults() {
@@ -367,7 +367,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2007-01-22 03:49:21',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_day_expecting_noresults() {
@@ -391,7 +391,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2009-06-11 21:30:28',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_hour_expecting_noresults() {
@@ -416,7 +416,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2008-07-15 11:32:26',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_minute_expecting_noresults() {
@@ -440,7 +440,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
'2010-06-17 17:09:30',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
}
public function test_simple_second_expecting_noresults() {