mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 15:47:05 +00:00
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:
@@ -33,8 +33,8 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
);
|
||||
$rfc3339 = $datetime->format( DATE_RFC3339 );
|
||||
|
||||
$this->assertEquals( 0, date_i18n( 'U', 0 ) );
|
||||
$this->assertEquals( $rfc3339, date_i18n( DATE_RFC3339, 0 ) );
|
||||
$this->assertSame( 0, date_i18n( 'U', 0 ) );
|
||||
$this->assertSame( $rfc3339, date_i18n( DATE_RFC3339, 0 ) );
|
||||
}
|
||||
|
||||
public function test_should_format_date() {
|
||||
@@ -42,7 +42,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_should_use_custom_timestamp() {
|
||||
$this->assertEquals( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) );
|
||||
$this->assertSame( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) );
|
||||
}
|
||||
|
||||
public function test_date_should_be_in_gmt() {
|
||||
@@ -64,7 +64,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
public function test_date_should_be_in_gmt_with_custom_timezone_setting_and_timestamp() {
|
||||
update_option( 'timezone_string', 'America/Regina' );
|
||||
|
||||
$this->assertEquals( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) );
|
||||
$this->assertSame( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) );
|
||||
}
|
||||
|
||||
public function test_adjusts_format_based_on_locale() {
|
||||
@@ -87,13 +87,13 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
// Restore original locale.
|
||||
$GLOBALS['wp_locale'] = $original_locale;
|
||||
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
public function test_adjusts_format_based_on_timezone_string() {
|
||||
update_option( 'timezone_string', 'America/Regina' );
|
||||
|
||||
$this->assertEquals( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) );
|
||||
$this->assertSame( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
$datetime = new DateTime( 'now', $datetimezone );
|
||||
$datetime = new DateTime( $datetime->format( 'P' ) );
|
||||
|
||||
$this->assertEquals( $datetime->format( $timezone_formats ), date_i18n( $timezone_formats ) );
|
||||
$this->assertSame( $datetime->format( $timezone_formats ), date_i18n( $timezone_formats ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
update_option( 'timezone_string', 'America/Regina' );
|
||||
|
||||
$this->assertEquals( strtotime( date_i18n( $full ) ), strtotime( date_i18n( $short ) ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( $short, date_i18n( '\\' . $short ) );
|
||||
$this->assertSame( $short, date_i18n( '\\' . $short ) );
|
||||
}
|
||||
|
||||
public function data_formats() {
|
||||
@@ -150,7 +150,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEquals( $wp_timestamp, date_i18n( 'U' ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( $timestamp, date_i18n( 'U', false, true ), 'The dates should be equal', 2 );
|
||||
$this->assertEquals( $wp_timestamp, date_i18n( 'U', $wp_timestamp ) );
|
||||
$this->assertSame( $wp_timestamp, date_i18n( 'U', $wp_timestamp ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,7 +159,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
public function test_swatch_internet_time_with_wp_timestamp() {
|
||||
update_option( 'timezone_string', 'America/Regina' );
|
||||
|
||||
$this->assertEquals( gmdate( 'B' ), date_i18n( 'B' ) );
|
||||
$this->assertSame( gmdate( 'B' ), date_i18n( 'B' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
public function test_should_handle_escaped_formats() {
|
||||
$format = 'D | \D | \\D | \\\D | \\\\D | \\\\\D | \\\\\\D';
|
||||
|
||||
$this->assertEquals( gmdate( $format ), date_i18n( $format ) );
|
||||
$this->assertSame( gmdate( $format ), date_i18n( $format ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
|
||||
$wp_timestamp = strtotime( $time );
|
||||
$format = 'I ' . DATE_RFC3339;
|
||||
|
||||
$this->assertEquals( $datetime->format( $format ), date_i18n( $format, $wp_timestamp ) );
|
||||
$this->assertSame( $datetime->format( $format ), date_i18n( $format, $wp_timestamp ) );
|
||||
}
|
||||
|
||||
public function dst_times() {
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase {
|
||||
public function test_get_comment_date_returns_correct_time_with_comment_id() {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$this->assertEquals( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) );
|
||||
$this->assertSame( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,8 +22,8 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase {
|
||||
public function test_get_comment_date_returns_correct_time_with_empty_format() {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$this->assertEquals( 'August 29, 2020', get_comment_date( '', $c ) );
|
||||
$this->assertEquals( 'August 29, 2020', get_comment_date( false, $c ) );
|
||||
$this->assertSame( 'August 29, 2020', get_comment_date( '', $c ) );
|
||||
$this->assertSame( 'August 29, 2020', get_comment_date( false, $c ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$GLOBALS['comment'] = get_comment( $c );
|
||||
$this->assertEquals( '1:51 am', get_comment_time( 'g:i a' ) );
|
||||
$this->assertSame( '1:51 am', get_comment_time( 'g:i a' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$GLOBALS['comment'] = get_comment( $c );
|
||||
$this->assertEquals( '1:51 am', get_comment_time( '' ) );
|
||||
$this->assertEquals( '1:51 am', get_comment_time( false ) );
|
||||
$this->assertSame( '1:51 am', get_comment_time( '' ) );
|
||||
$this->assertSame( '1:51 am', get_comment_time( false ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Tests_Date_Get_Feed_Build_Date extends WP_UnitTestCase {
|
||||
|
||||
$wp_query = new WP_Query( array( 'p' => $post_id ) );
|
||||
|
||||
$this->assertEquals( '2018-07-23T03:13:23+00:00', get_feed_build_date( DATE_RFC3339 ) );
|
||||
$this->assertSame( '2018-07-23T03:13:23+00:00', get_feed_build_date( DATE_RFC3339 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,10 +33,10 @@ class Tests_Date_Get_Permalink extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
|
||||
$this->assertSame( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
|
||||
|
||||
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
||||
date_default_timezone_set( $timezone );
|
||||
$this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
|
||||
$this->assertSame( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase {
|
||||
public function test_get_post_time_returns_correct_time_with_post_id() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
|
||||
|
||||
$this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
|
||||
$this->assertSame( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase {
|
||||
public function test_get_post_modified_time_returns_correct_time_with_post_id() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
|
||||
|
||||
$this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
|
||||
$this->assertSame( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,14 +64,14 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( $wp_timestamp, get_post_time( 'U', false, $post_id ) );
|
||||
$this->assertEquals( $wp_timestamp, get_post_time( 'G', false, $post_id ) );
|
||||
$this->assertEquals( $timestamp, get_post_time( 'U', true, $post_id ) );
|
||||
$this->assertEquals( $timestamp, get_post_time( 'G', true, $post_id ) );
|
||||
$this->assertEquals( $wp_timestamp, get_post_modified_time( 'U', false, $post_id ) );
|
||||
$this->assertEquals( $wp_timestamp, get_post_modified_time( 'G', false, $post_id ) );
|
||||
$this->assertEquals( $timestamp, get_post_modified_time( 'U', true, $post_id ) );
|
||||
$this->assertEquals( $timestamp, get_post_modified_time( 'G', true, $post_id ) );
|
||||
$this->assertSame( $wp_timestamp, get_post_time( 'U', false, $post_id ) );
|
||||
$this->assertSame( $wp_timestamp, get_post_time( 'G', false, $post_id ) );
|
||||
$this->assertSame( $timestamp, get_post_time( 'U', true, $post_id ) );
|
||||
$this->assertSame( $timestamp, get_post_time( 'G', true, $post_id ) );
|
||||
$this->assertSame( $wp_timestamp, get_post_modified_time( 'U', false, $post_id ) );
|
||||
$this->assertSame( $wp_timestamp, get_post_modified_time( 'G', false, $post_id ) );
|
||||
$this->assertSame( $timestamp, get_post_modified_time( 'U', true, $post_id ) );
|
||||
$this->assertSame( $timestamp, get_post_modified_time( 'G', true, $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,14 +92,14 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id ) );
|
||||
$this->assertEquals( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertEquals( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id, true ) );
|
||||
$this->assertEquals( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id, true ) );
|
||||
$this->assertEquals( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id ) );
|
||||
$this->assertEquals( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertEquals( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id, true ) );
|
||||
$this->assertEquals( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id, true ) );
|
||||
$this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id ) );
|
||||
$this->assertSame( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id, true ) );
|
||||
$this->assertSame( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id, true ) );
|
||||
$this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id ) );
|
||||
$this->assertSame( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id, true ) );
|
||||
$this->assertSame( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id, true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase {
|
||||
|
||||
update_option( 'timezone_string', 'Europe/Kiev' );
|
||||
|
||||
$this->assertEquals( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertEquals( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) );
|
||||
$this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase {
|
||||
public function test_get_the_date_returns_correct_time_with_post_id() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
|
||||
|
||||
$this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
|
||||
$this->assertSame( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,8 +32,8 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase {
|
||||
public function test_get_the_date_returns_correct_time_with_empty_format() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$this->assertEquals( 'August 29, 2020', get_the_date( '', $post_id ) );
|
||||
$this->assertEquals( 'August 29, 2020', get_the_date( false, $post_id ) );
|
||||
$this->assertSame( 'August 29, 2020', get_the_date( '', $post_id ) );
|
||||
$this->assertSame( 'August 29, 2020', get_the_date( false, $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase {
|
||||
public function test_get_the_time_returns_correct_time_with_post_id() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
|
||||
|
||||
$this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
|
||||
$this->assertSame( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase {
|
||||
public function test_get_the_time_returns_correct_time_with_empty_format() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$this->assertEquals( '1:51 am', get_the_time( '', $post_id ) );
|
||||
$this->assertEquals( '1:51 am', get_the_time( false, $post_id ) );
|
||||
$this->assertSame( '1:51 am', get_the_time( '', $post_id ) );
|
||||
$this->assertSame( '1:51 am', get_the_time( false, $post_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
$format = 'Y-m-d';
|
||||
$expected = '2016-01-21';
|
||||
$actual = get_the_modified_date( $format, $post_id );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
$expected = '2016-01-21';
|
||||
$format = 'Y-m-d';
|
||||
$actual = get_the_modified_date( $format );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,14 +63,14 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
$expected = 'filtered modified date failure result';
|
||||
add_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) );
|
||||
$actual = get_the_modified_date();
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
remove_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) );
|
||||
}
|
||||
|
||||
public function _filter_get_the_modified_date_failure( $the_date ) {
|
||||
$expected = false;
|
||||
$actual = $the_date;
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
|
||||
if ( false === $the_date ) {
|
||||
return 'filtered modified date failure result';
|
||||
@@ -94,8 +94,8 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
public function test_get_the_modified_date_returns_correct_time_with_empty_format() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2020-08-31 23:14:00' ) );
|
||||
|
||||
$this->assertEquals( 'August 31, 2020', get_the_modified_date( '', $post_id ) );
|
||||
$this->assertEquals( 'August 31, 2020', get_the_modified_date( false, $post_id ) );
|
||||
$this->assertSame( 'August 31, 2020', get_the_modified_date( '', $post_id ) );
|
||||
$this->assertSame( 'August 31, 2020', get_the_modified_date( false, $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,9 +112,9 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
);
|
||||
$post_id = $this->factory->post->create( $details );
|
||||
$format = 'G';
|
||||
$expected = '1453390476';
|
||||
$expected = 1453390476;
|
||||
$actual = get_the_modified_time( $format, $post_id );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,10 +134,10 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
|
||||
$GLOBALS['post'] = $post;
|
||||
|
||||
$expected = '1453390476';
|
||||
$expected = 1453390476;
|
||||
$format = 'G';
|
||||
$actual = get_the_modified_time( $format );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,14 +154,14 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
$expected = 'filtered modified time failure result';
|
||||
add_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) );
|
||||
$actual = get_the_modified_time();
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
remove_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) );
|
||||
}
|
||||
|
||||
public function _filter_get_the_modified_time_failure( $the_time ) {
|
||||
$expected = false;
|
||||
$actual = $the_time;
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
|
||||
if ( false === $the_time ) {
|
||||
return 'filtered modified time failure result';
|
||||
@@ -185,7 +185,7 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase {
|
||||
public function test_get_the_modified_time_returns_correct_time_with_empty_format() {
|
||||
$post_id = self::factory()->post->create( array( 'post_date' => '2020-08-31 23:14:00' ) );
|
||||
|
||||
$this->assertEquals( '11:14 pm', get_the_modified_time( '', $post_id ) );
|
||||
$this->assertEquals( '11:14 pm', get_the_modified_time( false, $post_id ) );
|
||||
$this->assertSame( '11:14 pm', get_the_modified_time( '', $post_id ) );
|
||||
$this->assertSame( '11:14 pm', get_the_modified_time( false, $post_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class Tests_Functions_MaybeDeclineDate extends WP_UnitTestCase {
|
||||
|
||||
remove_filter( 'gettext_with_context', array( $this, 'filter__enable_months_names_declension' ), 10 );
|
||||
|
||||
$this->assertEquals( $output, $declined_date );
|
||||
$this->assertSame( $output, $declined_date );
|
||||
}
|
||||
|
||||
public function filter__enable_months_names_declension( $translation, $text, $context ) {
|
||||
|
||||
@@ -24,8 +24,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
* @ticket 28310
|
||||
*/
|
||||
function test_mysql2date_returns_gmt_or_unix_timestamp() {
|
||||
$this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) );
|
||||
$this->assertEquals( '441013392', mysql2date( 'U', '1983-12-23 07:43:12' ) );
|
||||
$this->assertSame( 441013392, mysql2date( 'G', '1983-12-23 07:43:12' ) );
|
||||
$this->assertSame( 441013392, mysql2date( 'U', '1983-12-23 07:43:12' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,8 +38,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
$rfc3339 = $datetime->format( DATE_RFC3339 );
|
||||
$mysql = $datetime->format( 'Y-m-d H:i:s' );
|
||||
|
||||
$this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) );
|
||||
$this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) );
|
||||
$this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) );
|
||||
$this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,8 +54,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
$rfc3339 = $datetime->format( DATE_RFC3339 );
|
||||
$mysql = $datetime->format( 'Y-m-d H:i:s' );
|
||||
|
||||
$this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) );
|
||||
$this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) );
|
||||
$this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) );
|
||||
$this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +68,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
$wp_timestamp = $datetime->getTimestamp() + $datetime->getOffset();
|
||||
$mysql = $datetime->format( 'Y-m-d H:i:s' );
|
||||
|
||||
$this->assertEquals( $wp_timestamp, mysql2date( 'U', $mysql, false ) );
|
||||
$this->assertEquals( $wp_timestamp, mysql2date( 'G', $mysql, false ) );
|
||||
$this->assertSame( $wp_timestamp, mysql2date( 'U', $mysql, false ) );
|
||||
$this->assertSame( $wp_timestamp, mysql2date( 'G', $mysql, false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase {
|
||||
$timestamp = $datetime->getTimestamp();
|
||||
$mysql = $datetime->format( 'Y-m-d H:i:s' );
|
||||
|
||||
$this->assertEquals( $timestamp, mysql2date( 'U', $mysql, false ) );
|
||||
$this->assertEquals( $timestamp, mysql2date( 'G', $mysql, false ) );
|
||||
$this->assertSame( $timestamp, mysql2date( 'U', $mysql, false ) );
|
||||
$this->assertSame( $timestamp, mysql2date( 'G', $mysql, false ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
|
||||
'relation' => 'AND',
|
||||
);
|
||||
|
||||
$this->assertEquals( $expected, $q->queries );
|
||||
$this->assertSame( $expected, $q->queries );
|
||||
}
|
||||
|
||||
public function test_get_compare_empty() {
|
||||
@@ -1078,7 +1078,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( array( $p2 ), $q->posts );
|
||||
$this->assertSame( array( $p2 ), $q->posts );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1100,7 +1100,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals( array( $p2 ), $q->posts );
|
||||
$this->assertSame( array( $p2 ), $q->posts );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1124,7 +1124,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
// MySQL ignores the invalid clause.
|
||||
$this->assertEquals( array( $p1, $p2 ), $q->posts );
|
||||
$this->assertSame( array( $p1, $p2 ), $q->posts );
|
||||
}
|
||||
|
||||
/** Helpers */
|
||||
|
||||
@@ -61,20 +61,20 @@ class Tests_Date_The_Date extends WP_UnitTestCase {
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertEquals( 1, $this->hooks_called['the_time'] );
|
||||
$this->assertEquals( 2, $this->hooks_called['get_the_time'] );
|
||||
$this->assertSame( 1, $this->hooks_called['the_time'] );
|
||||
$this->assertSame( 2, $this->hooks_called['get_the_time'] );
|
||||
|
||||
$this->assertEquals( 1, $this->hooks_called['the_modified_time'] );
|
||||
$this->assertEquals( 2, $this->hooks_called['get_the_modified_time'] );
|
||||
$this->assertSame( 1, $this->hooks_called['the_modified_time'] );
|
||||
$this->assertSame( 2, $this->hooks_called['get_the_modified_time'] );
|
||||
|
||||
$this->assertEquals( 1, $this->hooks_called['the_date'] );
|
||||
$this->assertEquals( 2, $this->hooks_called['get_the_date'] );
|
||||
$this->assertSame( 1, $this->hooks_called['the_date'] );
|
||||
$this->assertSame( 2, $this->hooks_called['get_the_date'] );
|
||||
|
||||
$this->assertEquals( 1, $this->hooks_called['the_modified_date'] );
|
||||
$this->assertEquals( 2, $this->hooks_called['get_the_modified_date'] );
|
||||
$this->assertSame( 1, $this->hooks_called['the_modified_date'] );
|
||||
$this->assertSame( 2, $this->hooks_called['get_the_modified_date'] );
|
||||
|
||||
$this->assertEquals( 5, $this->hooks_called['get_post_time'] );
|
||||
$this->assertEquals( 5, $this->hooks_called['get_post_modified_time'] );
|
||||
$this->assertSame( 5, $this->hooks_called['get_post_time'] );
|
||||
$this->assertSame( 5, $this->hooks_called['get_post_modified_time'] );
|
||||
}
|
||||
|
||||
public function count_hook( $input ) {
|
||||
@@ -90,7 +90,7 @@ class Tests_Date_The_Date extends WP_UnitTestCase {
|
||||
ob_start();
|
||||
the_date();
|
||||
$actual = ob_get_clean();
|
||||
$this->assertEquals( '', $actual );
|
||||
$this->assertSame( '', $actual );
|
||||
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get(
|
||||
array(
|
||||
@@ -102,25 +102,25 @@ class Tests_Date_The_Date extends WP_UnitTestCase {
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
$GLOBALS['previousday'] = '17.09.15';
|
||||
the_date();
|
||||
$this->assertEquals( 'September 16, 2015', ob_get_clean() );
|
||||
$this->assertSame( 'September 16, 2015', ob_get_clean() );
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
$GLOBALS['previousday'] = '17.09.15';
|
||||
the_date( 'Y' );
|
||||
$this->assertEquals( '2015', ob_get_clean() );
|
||||
$this->assertSame( '2015', ob_get_clean() );
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
$GLOBALS['previousday'] = '17.09.15';
|
||||
the_date( 'Y', 'before ', ' after' );
|
||||
$this->assertEquals( 'before 2015 after', ob_get_clean() );
|
||||
$this->assertSame( 'before 2015 after', ob_get_clean() );
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
$GLOBALS['previousday'] = '17.09.15';
|
||||
the_date( 'Y', 'before ', ' after', false );
|
||||
$this->assertEquals( '', ob_get_clean() );
|
||||
$this->assertSame( '', ob_get_clean() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ class Tests_Date_The_Date extends WP_UnitTestCase {
|
||||
ob_start();
|
||||
the_weekday_date();
|
||||
$actual = ob_get_clean();
|
||||
$this->assertEquals( '', $actual );
|
||||
$this->assertSame( '', $actual );
|
||||
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get(
|
||||
array(
|
||||
@@ -142,12 +142,12 @@ class Tests_Date_The_Date extends WP_UnitTestCase {
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
$GLOBALS['previousweekday'] = '17.09.15';
|
||||
the_weekday_date();
|
||||
$this->assertEquals( 'Wednesday', ob_get_clean() );
|
||||
$this->assertSame( 'Wednesday', ob_get_clean() );
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
$GLOBALS['previousweekday'] = '17.09.15';
|
||||
the_weekday_date( 'before ', ' after' );
|
||||
$this->assertEquals( 'before Wednesday after', ob_get_clean() );
|
||||
$this->assertSame( 'before Wednesday after', ob_get_clean() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class Tests_Date_WP_Date extends WP_UnitTestCase {
|
||||
$utc = new DateTimeZone( 'UTC' );
|
||||
$datetime = new DateTimeImmutable( '2019-10-17', $utc );
|
||||
|
||||
$this->assertEquals( '10月', wp_date( 'F', $datetime->getTimestamp(), $utc ) );
|
||||
$this->assertSame( '10月', wp_date( 'F', $datetime->getTimestamp(), $utc ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,6 +58,6 @@ class Tests_Date_WP_Date extends WP_UnitTestCase {
|
||||
$utc = new DateTimeZone( 'UTC' );
|
||||
$datetime = new DateTimeImmutable( '2019-10-17', $utc );
|
||||
|
||||
$this->assertEquals( $string, wp_date( 'F', $datetime->getTimestamp(), $utc ) );
|
||||
$this->assertSame( $string, wp_date( 'F', $datetime->getTimestamp(), $utc ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ class Tests_Date_WP_Timezone extends WP_UnitTestCase {
|
||||
delete_option( 'timezone_string' );
|
||||
update_option( 'gmt_offset', $gmt_offset );
|
||||
|
||||
$this->assertEquals( $tz_name, wp_timezone_string() );
|
||||
$this->assertSame( $tz_name, wp_timezone_string() );
|
||||
|
||||
$timezone = wp_timezone();
|
||||
|
||||
$this->assertEquals( $tz_name, $timezone->getName() );
|
||||
$this->assertSame( $tz_name, $timezone->getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,11 +31,11 @@ class Tests_Date_WP_Timezone extends WP_UnitTestCase {
|
||||
public function test_should_return_timezone_string() {
|
||||
update_option( 'timezone_string', 'Europe/Kiev' );
|
||||
|
||||
$this->assertEquals( 'Europe/Kiev', wp_timezone_string() );
|
||||
$this->assertSame( 'Europe/Kiev', wp_timezone_string() );
|
||||
|
||||
$timezone = wp_timezone();
|
||||
|
||||
$this->assertEquals( 'Europe/Kiev', $timezone->getName() );
|
||||
$this->assertSame( 'Europe/Kiev', $timezone->getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$post->post_date,
|
||||
'UTC time with explicit time zone into mw_newPost'
|
||||
@@ -55,7 +55,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$post->post_date,
|
||||
'Local time w/o time zone into mw_newPost'
|
||||
@@ -76,7 +76,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$post->post_date,
|
||||
'UTC time into mw_newPost'
|
||||
@@ -97,7 +97,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$post->post_date,
|
||||
'Local time into wp_newPost'
|
||||
@@ -118,7 +118,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$post->post_date,
|
||||
'UTC time into wp_newPost'
|
||||
@@ -158,7 +158,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
$fetched_post = get_post( $post_id );
|
||||
|
||||
$this->assertTrue( $result );
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$fetched_post->post_date,
|
||||
'Local time into mw_editPost'
|
||||
@@ -185,7 +185,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
$fetched_post = get_post( $post_id );
|
||||
|
||||
$this->assertTrue( $result );
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$fetched_post->post_date,
|
||||
'UTC time into mw_editPost'
|
||||
@@ -231,7 +231,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase {
|
||||
$fetched_comment = get_comment( $comment_id );
|
||||
|
||||
$this->assertTrue( $result );
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$datetime->format( 'Y-m-d H:i:s' ),
|
||||
$fetched_comment->comment_date,
|
||||
'UTC time into wp_editComment'
|
||||
|
||||
Reference in New Issue
Block a user