Date/Time: Replace all instances of date() with gmdate().

Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

`gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.

git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-05-26 00:11:37 +00:00
parent 716e25e0df
commit 10855438ea
49 changed files with 231 additions and 231 deletions

View File

@@ -10,7 +10,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
$this->assertEquals( $post->post_name, $data['slug'] );
$this->assertEquals( get_permalink( $post->ID ), $data['link'] );
if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) {
$post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) );
$post_date_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_date ) - ( get_option( 'gmt_offset' ) * 3600 ) );
$this->assertEquals( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] );
} else {
$this->assertEquals( mysql_to_rfc3339( $post->post_date_gmt ), $data['date_gmt'] );
@@ -18,7 +18,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
$this->assertEquals( mysql_to_rfc3339( $post->post_date ), $data['date'] );
if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) {
$post_modified_gmt = date( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) );
$post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) );
$this->assertEquals( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] );
} else {
$this->assertEquals( mysql_to_rfc3339( $post->post_modified_gmt ), $data['modified_gmt'] );

View File

@@ -164,7 +164,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
$this->assertNotWPError( $response );
$this->assertEqualSetsWithIndex( $this->get_user_location(), $response['location'] );
$this->assertEquals( date( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] );
$this->assertEquals( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] );
$this->assertEquals( '1:00 pm', $response['events'][0]['formatted_time'] );
remove_filter( 'pre_http_request', array( $this, '_http_request_valid_response' ) );
@@ -185,7 +185,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
$this->assertNotWPError( $cached_events );
$this->assertEqualSetsWithIndex( $this->get_user_location(), $cached_events['location'] );
$this->assertEquals( date( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] );
$this->assertEquals( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] );
$this->assertEquals( '1:00 pm', $cached_events['events'][0]['formatted_time'] );
remove_filter( 'pre_http_request', array( $this, '_http_request_valid_response' ) );
@@ -211,7 +211,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/events/236031233/',
'meetup' => 'The East Bay WordPress Meetup Group',
'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Sunday 1pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Sunday 1pm' ) ),
'location' => array(
'location' => 'Oakland, CA, USA',
'country' => 'us',
@@ -225,7 +225,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/events/237706839/',
'meetup' => 'WordPress Bay Area Foothills Group',
'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
'location' => array(
'location' => 'Milpitas, CA, USA',
'country' => 'us',
@@ -239,7 +239,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://2017.kansascity.wordcamp.org',
'meetup' => null,
'meetup_url' => null,
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Saturday' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Saturday' ) ),
'location' => array(
'location' => 'Kansas City, MO',
'country' => 'US',
@@ -303,7 +303,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/events/236031233/',
'meetup' => 'The East Bay WordPress Meetup Group',
'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Monday 1pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Monday 1pm' ) ),
'location' => array(
'location' => 'Oakland, CA, USA',
'country' => 'us',
@@ -317,7 +317,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/events/237706839/',
'meetup' => 'WordPress Bay Area Foothills Group',
'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Tuesday 1:30pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Tuesday 1:30pm' ) ),
'location' => array(
'location' => 'Milpitas, CA, USA',
'country' => 'us',
@@ -331,7 +331,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/sanjosewp/events/245419844/',
'meetup' => 'The San Jose WordPress Meetup',
'meetup_url' => 'https://www.meetup.com/sanjosewp/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 5:30pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Wednesday 5:30pm' ) ),
'location' => array(
'location' => 'Milpitas, CA, USA',
'country' => 'us',
@@ -345,7 +345,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://2018.sandiego.wordcamp.org',
'meetup' => null,
'meetup_url' => null,
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Thursday 9am' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Thursday 9am' ) ),
'location' => array(
'location' => 'San Diego, CA',
'country' => 'US',
@@ -406,7 +406,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/events/236031233/',
'meetup' => 'The East Bay WordPress Meetup Group',
'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
'date' => date( 'Y-m-d H:i:s', strtotime( '2 days ago' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( '2 days ago' ) ),
'location' => array(
'location' => 'Oakland, CA, USA',
'country' => 'us',
@@ -420,7 +420,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://2018.sandiego.wordcamp.org',
'meetup' => null,
'meetup_url' => null,
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Tuesday 9am' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Tuesday 9am' ) ),
'location' => array(
'location' => 'San Diego, CA',
'country' => 'US',
@@ -434,7 +434,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/events/237706839/',
'meetup' => 'WordPress Bay Area Foothills Group',
'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
'location' => array(
'location' => 'Milpitas, CA, USA',
'country' => 'us',
@@ -448,7 +448,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://www.meetup.com/sanjosewp/events/245419844/',
'meetup' => 'The San Jose WordPress Meetup',
'meetup_url' => 'https://www.meetup.com/sanjosewp/',
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Thursday 5:30pm' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Thursday 5:30pm' ) ),
'location' => array(
'location' => 'Milpitas, CA, USA',
'country' => 'us',
@@ -462,7 +462,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
'url' => 'https://2018.la.wordcamp.org',
'meetup' => null,
'meetup_url' => null,
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Friday 9am' ) ),
'date' => gmdate( 'Y-m-d H:i:s', strtotime( 'next Friday 9am' ) ),
'location' => array(
'location' => 'Los Angeles, CA',
'country' => 'US',

View File

@@ -355,7 +355,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
$permalink_structure = '%postname%';
$this->set_permalink_structure( "/$permalink_structure/" );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$future_date = gmdate( 'Y-m-d H:i:s', time() + 100 );
$p = self::factory()->post->create(
array(
'post_status' => 'future',
@@ -377,7 +377,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_link_when_pretty_permalinks_are_disabled() {
wp_set_current_user( self::$admin_id );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$future_date = gmdate( 'Y-m-d H:i:s', time() + 100 );
$p = self::factory()->post->create(
array(
'post_status' => 'future',
@@ -400,7 +400,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
wp_set_current_user( self::$admin_id );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$future_date = gmdate( 'Y-m-d H:i:s', time() + 100 );
$p = self::factory()->post->create(
array(
'post_status' => 'future',
@@ -464,7 +464,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
$this->assertContains( '>new_slug-صورة<', $found, $message );
// Scheduled posts should use published permalink
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$future_date = gmdate( 'Y-m-d H:i:s', time() + 100 );
$p = self::factory()->post->create(
array(
'post_status' => 'future',
@@ -507,7 +507,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
wp_set_current_user( self::$admin_id );
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
$future_date = gmdate( 'Y-m-d H:i:s', time() + 100 );
$p = self::factory()->post->create(
array(
'post_status' => 'pending',

View File

@@ -13,7 +13,7 @@ class Tests_Basic extends WP_UnitTestCase {
$license = file_get_contents( ABSPATH . 'license.txt' );
preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches );
$this_year = date( 'Y' );
$this_year = gmdate( 'Y' );
$this->assertEquals( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." );
}

View File

@@ -133,7 +133,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
$post = self::factory()->post->create_and_get(
array(
'post_date' => date( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
'post_date' => gmdate( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
)
);

View File

@@ -17,14 +17,14 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
@@ -51,14 +51,14 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
@@ -85,14 +85,14 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
@@ -119,14 +119,14 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
@@ -153,42 +153,42 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
$comment_5 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 500 ),
)
);
$comment_6 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 600 ),
)
);
@@ -224,42 +224,42 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
$comment_5 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 500 ),
)
);
$comment_6 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 600 ),
)
);
@@ -295,28 +295,28 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
@@ -352,28 +352,28 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
@@ -411,21 +411,21 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
@@ -463,21 +463,21 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
@@ -513,28 +513,28 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
@@ -592,42 +592,42 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
$comment_5 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 500 ),
)
);
$comment_6 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 600 ),
)
);
@@ -706,7 +706,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
@@ -714,7 +714,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
@@ -722,7 +722,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_4 = self::factory()->comment->create(
@@ -730,7 +730,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_approved' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
@@ -762,7 +762,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
@@ -770,7 +770,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
@@ -778,7 +778,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '3',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
'comment_author_email' => $comment_author_email,
)
);
@@ -787,7 +787,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '4',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
'comment_author_email' => $comment_author_email,
)
);
@@ -796,7 +796,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '5',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
'comment_author_email' => $comment_author_email,
)
);
@@ -805,7 +805,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '6',
'comment_approved' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
@@ -842,7 +842,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_approved' => '0',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
'comment_author_email' => 'foo@bar.mail',
)
);
@@ -878,7 +878,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_approved' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
$comment_2 = self::factory()->comment->create(
@@ -886,7 +886,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_approved' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_3 = self::factory()->comment->create(
@@ -895,7 +895,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_content' => '3',
'comment_approved' => '1',
'comment_parent' => $comment_1,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
@@ -923,7 +923,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '1',
'comment_approved' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
$comment_2 = self::factory()->comment->create(
@@ -931,7 +931,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_post_ID' => $p,
'comment_content' => '2',
'comment_approved' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
$comment_3 = self::factory()->comment->create(
@@ -940,7 +940,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
'comment_content' => '3',
'comment_approved' => '1',
'comment_parent' => $comment_1,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);

View File

@@ -15,42 +15,42 @@ class Tests_Comment_GetCommentLink extends WP_UnitTestCase {
array(
'comment_post_ID' => self::$p,
'comment_content' => '1',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 100 ),
)
);
self::$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => self::$p,
'comment_content' => '2',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 200 ),
)
);
self::$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => self::$p,
'comment_content' => '3',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 300 ),
)
);
self::$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => self::$p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 400 ),
)
);
self::$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => self::$p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 500 ),
)
);
self::$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => self::$p,
'comment_content' => '4',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 600 ),
)
);

View File

@@ -45,7 +45,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_type' => 'trackback',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
$now -= 10 * $i;
@@ -57,7 +57,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_type' => 'pingback',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
$now -= 10 * $i;
@@ -135,7 +135,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
array(
'comment_post_ID' => $p,
'comment_type' => 'trackback',
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( 10 * $i ) ),
)
);
}
@@ -226,20 +226,20 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$c1 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
$c2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
)
);
$c3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_approved' => 0,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
)
);
@@ -262,13 +262,13 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$comments_0[] = self::factory()->comment->create(
array(
'comment_post_ID' => $posts[0],
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
)
);
$comments_1[] = self::factory()->comment->create(
array(
'comment_post_ID' => $posts[1],
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
)
);
}
@@ -292,7 +292,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$parent = self::factory()->comment->create(
array(
'comment_post_ID' => $post,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 60 ) ),
)
);
$comment_parents[ $i ] = $parent;
@@ -300,7 +300,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$child = self::factory()->comment->create(
array(
'comment_post_ID' => $post,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( $i * 59 ) ),
'comment_parent' => $parent,
)
);
@@ -336,19 +336,19 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$c1 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
$c2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
)
);
$c3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
)
);
@@ -369,25 +369,25 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$c1 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
$c2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
)
);
$c3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
)
);
$c4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
)
);
@@ -409,25 +409,25 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$c1 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
$c2 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
)
);
$c3 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
)
);
$c4 = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
)
);

View File

@@ -142,7 +142,7 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $posts[0],
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
)
);
}
@@ -190,7 +190,7 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $posts[0],
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
)
);
}

View File

@@ -2949,25 +2949,25 @@ class Tests_Comment_Query extends WP_UnitTestCase {
$c1 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 50 ),
)
);
$c2 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
)
);
$c3 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
)
);
$c4 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
)
);
@@ -2995,25 +2995,25 @@ class Tests_Comment_Query extends WP_UnitTestCase {
$c1 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 50 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 50 ),
)
);
$c2 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 40 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 40 ),
)
);
$c3 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 30 ),
)
);
$c4 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - 20 ),
)
);

View File

@@ -42,7 +42,7 @@ class Tests_Comment_WpAllowComment extends WP_UnitTestCase {
'comment_content' => 'Yes, we can!',
'comment_author_IP' => '192.168.0.1',
'comment_parent' => 0,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
'comment_agent' => 'Bobbot/2.1',
'comment_type' => '',
);
@@ -65,7 +65,7 @@ class Tests_Comment_WpAllowComment extends WP_UnitTestCase {
'comment_content' => 'Yes, we can!',
'comment_author_IP' => '192.168.0.1',
'comment_parent' => 0,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now ),
'comment_agent' => 'Bobbot/2.1',
'comment_type' => '',
);

View File

@@ -16,7 +16,7 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - $i ),
'comment_author' => 'Commenter ' . $i,
)
);
@@ -54,7 +54,7 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - $i ),
'comment_author' => 'Commenter ' . $i,
)
);
@@ -92,7 +92,7 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - $i ),
'comment_author' => 'Commenter ' . $i,
)
);
@@ -138,7 +138,7 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - $i ),
'comment_author' => 'Commenter ' . $i,
)
);
@@ -178,7 +178,7 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - $i ),
'comment_author' => 'Commenter ' . $i,
)
);
@@ -223,7 +223,7 @@ class Tests_Comment_WpListComments extends WP_UnitTestCase {
$comments[] = self::factory()->comment->create(
array(
'comment_post_ID' => $p,
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ),
'comment_date_gmt' => gmdate( 'Y-m-d H:i:s', $now - $i ),
'comment_author' => 'Commenter ' . $i,
'user_id' => $u,
)

View File

@@ -6,7 +6,7 @@
*/
class Tests_Date_I18n extends WP_UnitTestCase {
public function test_should_format_date() {
$this->assertEquals( strtotime( date( 'Y-m-d H:i:s' ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
$this->assertEquals( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
}
public function test_should_use_custom_timestamp() {
@@ -14,7 +14,7 @@ class Tests_Date_I18n extends WP_UnitTestCase {
}
public function test_date_should_be_in_gmt() {
$this->assertEquals( strtotime( date( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
$this->assertEquals( strtotime( gmdate( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
}
public function test_custom_timestamp_ignores_gmt_setting() {
@@ -24,13 +24,13 @@ class Tests_Date_I18n extends WP_UnitTestCase {
public function test_custom_timezone_setting() {
update_option( 'timezone_string', 'America/Regina' );
$this->assertEquals( strtotime( date( 'Y-m-d H:i:s', time() + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
$this->assertEquals( strtotime( gmdate( 'Y-m-d H:i:s', time() + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ), strtotime( date_i18n( 'Y-m-d H:i:s' ) ), 'The dates should be equal', 2 );
}
public function test_date_should_be_in_gmt_with_custom_timezone_setting() {
update_option( 'timezone_string', 'America/Regina' );
$this->assertEquals( strtotime( date( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
$this->assertEquals( strtotime( gmdate( DATE_RFC3339 ) ), strtotime( date_i18n( DATE_RFC3339, false, true ) ), 'The dates should be equal', 2 );
}
public function test_date_should_be_in_gmt_with_custom_timezone_setting_and_timestamp() {

View File

@@ -15,8 +15,8 @@ class Tests_Get_Archives extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->month_url = get_month_link( date( 'Y' ), date( 'm' ) );
$this->year_url = get_year_link( date( 'Y' ) );
$this->month_url = get_month_link( gmdate( 'Y' ), gmdate( 'm' ) );
$this->year_url = get_year_link( gmdate( 'Y' ) );
}
public static function wpSetUpBeforeClass( $factory ) {
@@ -30,12 +30,12 @@ class Tests_Get_Archives extends WP_UnitTestCase {
}
function test_wp_get_archives_default() {
$expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>';
$expected['default'] = "<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></li>';
$this->assertEquals( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) );
}
function test_wp_get_archives_type() {
$expected['type'] = "<li><a href='" . $this->year_url . "'>" . date( 'Y' ) . '</a></li>';
$expected['type'] = "<li><a href='" . $this->year_url . "'>" . gmdate( 'Y' ) . '</a></li>';
$this->assertEquals(
$expected['type'],
trim(
@@ -86,7 +86,7 @@ EOF;
}
function test_wp_get_archives_format() {
$expected['format'] = "<option value='" . $this->month_url . "'> " . date( 'F Y' ) . ' </option>';
$expected['format'] = "<option value='" . $this->month_url . "'> " . gmdate( 'F Y' ) . ' </option>';
$this->assertEquals(
$expected['format'],
trim(
@@ -101,7 +101,7 @@ EOF;
}
function test_wp_get_archives_before_and_after() {
$expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></div>';
$expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></div>';
$this->assertEquals(
$expected['before_and_after'],
trim(
@@ -118,7 +118,7 @@ EOF;
}
function test_wp_get_archives_show_post_count() {
$expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a>&nbsp;(8)</li>';
$expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a>&nbsp;(8)</li>';
$this->assertEquals(
$expected['show_post_count'],
trim(
@@ -133,7 +133,7 @@ EOF;
}
function test_wp_get_archives_echo() {
$expected['echo'] = "\t<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . '</a></li>' . "\n";
$expected['echo'] = "\t<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></li>' . "\n";
$this->expectOutputString( $expected['echo'] );
wp_get_archives( array( 'echo' => true ) );
}
@@ -147,7 +147,7 @@ EOF;
)
);
$date_full = date( 'F Y' );
$date_full = gmdate( 'F Y' );
$oct_url = get_month_link( 2012, 10 );
$expected['order_asc'] = <<<EOF
<li><a href='{$oct_url}'>October 2012</a></li>

View File

@@ -1428,7 +1428,7 @@ EOF;
function test_wp_calculate_image_srcset() {
$_wp_additional_image_sizes = wp_get_additional_image_sizes();
$year_month = date( 'Y/m' );
$year_month = gmdate( 'Y/m' );
$image_meta = wp_get_attachment_metadata( self::$large_id );
$uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
@@ -1550,7 +1550,7 @@ EOF;
function test_wp_calculate_image_srcset_with_absolute_path_in_meta() {
$_wp_additional_image_sizes = wp_get_additional_image_sizes();
$year_month = date( 'Y/m' );
$year_month = gmdate( 'Y/m' );
$image_meta = wp_get_attachment_metadata( self::$large_id );
$uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
@@ -1831,7 +1831,7 @@ EOF;
$srcset = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta );
$year_month = date( 'Y/m' );
$year_month = gmdate( 'Y/m' );
$uploads_dir = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
// Set up test cases for all expected size names.
@@ -2228,8 +2228,8 @@ EOF;
remove_all_filters( 'wp_calculate_image_sizes' );
$actual = wp_get_attachment_image( self::$large_id, 'testsize' );
$year = date( 'Y' );
$month = date( 'm' );
$year = gmdate( 'Y' );
$month = gmdate( 'm' );
$expected = '<img width="999" height="999" src="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year . '/' . $month . '/test-image-testsize-999x999.png"' .
' class="attachment-testsize size-testsize" alt=""' .

View File

@@ -99,7 +99,7 @@ if ( is_multisite() ) :
remove_filter( 'wpmu_signup_user_notification', '__return_true' );
global $wpdb;
$date = date( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
$date = gmdate( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
$wpdb->update( $wpdb->signups, array( 'registered' => $date ), array( 'user_login' => 'foo123' ) );
$v = wpmu_validate_user_signup( 'foo123', 'foo2@example.com' );
@@ -123,7 +123,7 @@ if ( is_multisite() ) :
remove_filter( 'wpmu_signup_user_notification', '__return_true' );
global $wpdb;
$date = date( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
$date = gmdate( 'Y-m-d H:i:s', time() - ( 2 * DAY_IN_SECONDS ) - 60 );
$wpdb->update( $wpdb->signups, array( 'registered' => $date ), array( 'user_login' => 'foo123' ) );
$v = wpmu_validate_user_signup( 'foo2', 'foo2@example.com' );

View File

@@ -49,7 +49,7 @@ class Tests_List_Pages extends WP_UnitTestCase {
public static function wpSetupBeforeClass() {
self::$time = time();
$post_date = date( 'Y-m-d H:i:s', self::$time );
$post_date = gmdate( 'Y-m-d H:i:s', self::$time );
self::$parent_1 = self::factory()->post->create(
array(
@@ -157,7 +157,7 @@ class Tests_List_Pages extends WP_UnitTestCase {
'depth' => 1,
'show_date' => true,
);
$date = date( get_option( 'date_format' ), self::$time );
$date = gmdate( get_option( 'date_format' ), self::$time );
$expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a> ' . $date . '</li>
<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a> ' . $date . '</li>
@@ -173,7 +173,7 @@ class Tests_List_Pages extends WP_UnitTestCase {
'show_date' => true,
'date_format' => 'l, F j, Y',
);
$date = date( $args['date_format'], self::$time );
$date = gmdate( $args['date_format'], self::$time );
$expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a> ' . $date . '
<ul class=\'children\'>

View File

@@ -532,7 +532,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
$now = time();
for ( $j = 1; $j < 3; $j++ ) {
// Manually modify dates to ensure they're different.
$date = date( 'Y-m-d H:i:s', $now - ( $j * 10 ) );
$date = gmdate( 'Y-m-d H:i:s', $now - ( $j * 10 ) );
$post_revision_fields['post_date'] = $date;
$post_revision_fields['post_date_gmt'] = $date;
@@ -563,7 +563,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
$post_revision_fields = wp_slash( $post_revision_fields );
$revision_ids = array();
$date = date( 'Y-m-d H:i:s', time() - 10 );
$date = gmdate( 'Y-m-d H:i:s', time() - 10 );
for ( $j = 1; $j < 3; $j++ ) {
// Manually modify dates to ensure they're the same.
$post_revision_fields['post_date'] = $date;

View File

@@ -12,7 +12,7 @@ class Tests_Query_Stickies extends WP_UnitTestCase {
// Set post times to get a reliable order.
$now = time();
for ( $i = 0; $i <= 22; $i++ ) {
$post_date = date( 'Y-m-d H:i:s', $now - ( 10 * $i ) );
$post_date = gmdate( 'Y-m-d H:i:s', $now - ( 10 * $i ) );
self::$posts[ $i ] = $factory->post->create(
array(
'post_date' => $post_date,
@@ -28,7 +28,7 @@ class Tests_Query_Stickies extends WP_UnitTestCase {
public function test_stickies_should_be_ignored_when_is_home_is_false() {
$q = new WP_Query(
array(
'year' => date( 'Y' ),
'year' => gmdate( 'Y' ),
'fields' => 'ids',
'posts_per_page' => 3,
)

View File

@@ -2010,8 +2010,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$this->assertEquals( 'draft', $data['status'] );
$this->assertEquals( 'draft', $new_post->post_status );
// Confirm dates are shimmed for gmt_offset
$post_modified_gmt = date( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) );
$post_date_gmt = date( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) );
$post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) );
$post_date_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) );
$this->assertEquals( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] );
$this->assertEquals( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] );
@@ -2736,8 +2736,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$this->assertEquals( $new_content, $new_post->post_content );
// The modified date should equal the current time.
$this->assertEquals( date( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), date( 'Y-m-d', strtotime( $data['modified'] ) ) );
$this->assertEquals( date( 'Y-m-d', strtotime( $expected_modified ) ), date( 'Y-m-d', strtotime( $new_post->post_modified ) ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) );
$this->assertEquals( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) );
}
/**

View File

@@ -2791,7 +2791,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertEquals( $user->user_email, $data['email'] );
$this->assertEquals( (object) $user->allcaps, $data['capabilities'] );
$this->assertEquals( (object) $user->caps, $data['extra_capabilities'] );
$this->assertEquals( date( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] );
$this->assertEquals( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] );
$this->assertEquals( $user->user_login, $data['username'] );
$this->assertEquals( $user->roles, $data['roles'] );
$this->assertEquals( get_user_locale( $user ), $data['locale'] );

View File

@@ -336,8 +336,8 @@ class Tests_URL extends WP_UnitTestCase {
public function test_get_adjacent_post() {
$now = time();
$post_id = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
$post_id2 = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
$post_id = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ) ) );
$post_id2 = self::factory()->post->create( array( 'post_date' => gmdate( 'Y-m-d H:i:s', $now ) ) );
if ( ! isset( $GLOBALS['post'] ) ) {
$GLOBALS['post'] = null;
@@ -379,13 +379,13 @@ class Tests_URL extends WP_UnitTestCase {
array(
'post_author' => $u,
'post_status' => 'private',
'post_date' => date( 'Y-m-d H:i:s', $now - 1 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ),
)
);
$p2 = self::factory()->post->create(
array(
'post_author' => $u,
'post_date' => date( 'Y-m-d H:i:s', $now ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
@@ -417,13 +417,13 @@ class Tests_URL extends WP_UnitTestCase {
array(
'post_author' => $u1,
'post_status' => 'private',
'post_date' => date( 'Y-m-d H:i:s', $now - 1 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ),
)
);
$p2 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_date' => date( 'Y-m-d H:i:s', $now ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now ),
)
);
@@ -454,20 +454,20 @@ class Tests_URL extends WP_UnitTestCase {
$p1 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_date' => date( 'Y-m-d H:i:s', $now - 2 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 2 ),
)
);
$p2 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_status' => 'private',
'post_date' => date( 'Y-m-d H:i:s', $now - 1 ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now - 1 ),
)
);
$p3 = self::factory()->post->create(
array(
'post_author' => $u1,
'post_date' => date( 'Y-m-d H:i:s', $now ),
'post_date' => gmdate( 'Y-m-d H:i:s', $now ),
)
);

View File

@@ -274,7 +274,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
'post_content' => 'Not edited',
'post_author' => $editor_id,
'post_status' => 'publish',
'post_date' => date( 'Y-m-d H:i:s', $yesterday ),
'post_date' => gmdate( 'Y-m-d H:i:s', $yesterday ),
)
);

View File

@@ -60,7 +60,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
$post_ids[] = self::factory()->post->create(
array(
'post_type' => $cpt_name,
'post_date' => date( 'Y-m-d H:i:s', time() + $i ),
'post_date' => gmdate( 'Y-m-d H:i:s', time() + $i ),
)
);
}