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

@ -1476,7 +1476,7 @@ function wp_ajax_add_meta() {
$post_data['post_status'] = 'draft';
$now = time();
/* translators: 1: Post creation date, 2: Post creation time */
$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) );
$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), gmdate( __( 'F j, Y' ), $now ), gmdate( __( 'g:i a' ), $now ) );
$pid = edit_post( $post_data );
if ( $pid ) {

View File

@ -207,7 +207,7 @@ class ftp_base {
$b['month'] = $lucifer[5];
$b['day'] = $lucifer[6];
if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
$b['year'] = date("Y");
$b['year'] = gmdate("Y");
$b['hour'] = $l2[1];
$b['minute'] = $l2[2];
} else {

View File

@ -598,8 +598,8 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
$struc['group'] = $this->group( $path . '/' . $entry );
$struc['size'] = $this->size( $path . '/' . $entry );
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
$struc['lastmod'] = date( 'M j', $struc['lastmodunix'] );
$struc['time'] = date( 'h:i:s', $struc['lastmodunix'] );
$struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] );
$struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] );
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
if ( 'd' == $struc['type'] ) {

View File

@ -621,7 +621,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$b['month'] = $lucifer[5];
$b['day'] = $lucifer[6];
if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2 ) ) {
$b['year'] = date( 'Y' );
$b['year'] = gmdate( 'Y' );
$b['hour'] = $l2[1];
$b['minute'] = $l2[2];
} else {

View File

@ -744,8 +744,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$struc['group'] = $this->group( $path . '/' . $entry );
$struc['size'] = $this->size( $path . '/' . $entry );
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
$struc['lastmod'] = date( 'M j', $struc['lastmodunix'] );
$struc['time'] = date( 'h:i:s', $struc['lastmodunix'] );
$struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] );
$struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] );
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
if ( 'd' == $struc['type'] ) {

View File

@ -863,11 +863,11 @@ function wp_dashboard_recent_posts( $args ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( date( 'Y-m-d', $time ) == $today ) {
if ( gmdate( 'Y-m-d', $time ) == $today ) {
$relative = __( 'Today' );
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
} elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( date( 'Y', $time ) !== $year ) {
} elseif ( gmdate( 'Y', $time ) !== $year ) {
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {

View File

@ -79,7 +79,7 @@ function export_wp( $args = array() ) {
if ( ! empty( $sitename ) ) {
$sitename .= '.';
}
$date = date( 'Y-m-d' );
$date = gmdate( 'Y-m-d' );
$wp_filename = $sitename . 'WordPress.' . $date . '.xml';
/**
* Filters the export filename.
@ -129,11 +129,11 @@ function export_wp( $args = array() ) {
}
if ( $args['start_date'] ) {
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime( $args['start_date'] ) ) );
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", gmdate( 'Y-m-d', strtotime( $args['start_date'] ) ) );
}
if ( $args['end_date'] ) {
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) );
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", gmdate( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) );
}
}
@ -458,7 +458,7 @@ function export_wp( $args = array() ) {
<title><?php bloginfo_rss( 'name' ); ?></title>
<link><?php bloginfo_rss( 'url' ); ?></link>
<description><?php bloginfo_rss( 'description' ); ?></description>
<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
<pubDate><?php echo gmdate( 'D, d M Y H:i:s +0000' ); ?></pubDate>
<language><?php bloginfo_rss( 'language' ); ?></language>
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>

View File

@ -170,10 +170,10 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
$hh = $post_data['hh'];
$mn = $post_data['mn'];
$ss = $post_data['ss'];
$aa = ( $aa <= 0 ) ? date( 'Y' ) : $aa;
$mm = ( $mm <= 0 ) ? date( 'n' ) : $mm;
$aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa;
$mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm;
$jj = ( $jj > 31 ) ? 31 : $jj;
$jj = ( $jj <= 0 ) ? date( 'j' ) : $jj;
$jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj;
$hh = ( $hh > 23 ) ? $hh - 24 : $hh;
$mn = ( $mn > 59 ) ? $mn - 60 : $mn;
$ss = ( $ss > 59 ) ? $ss - 60 : $ss;

View File

@ -941,7 +941,7 @@ function upgrade_110() {
$time_difference = $all_options->time_difference;
$server_time = time() + date( 'Z' );
$server_time = time() + gmdate( 'Z' );
$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
$gmt_time = time();

View File

@ -202,11 +202,11 @@ $structures = array(
</tr>
<tr>
<th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[1] ); ?>" <?php checked( $structures[1], $permalink_structure ); ?> /> <?php _e( 'Day and name' ); ?></label></th>
<td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . date( 'Y' ) . '/' . date( 'm' ) . '/' . date( 'd' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
<td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . gmdate( 'd' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
</tr>
<tr>
<th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[2] ); ?>" <?php checked( $structures[2], $permalink_structure ); ?> /> <?php _e( 'Month and name' ); ?></label></th>
<td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . date( 'Y' ) . '/' . date( 'm' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
<td><code><?php echo get_option( 'home' ) . $blog_prefix . $prefix . '/' . gmdate( 'Y' ) . '/' . gmdate( 'm' ) . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
</tr>
<tr>
<th scope="row"><label><input name="selection" type="radio" value="<?php echo esc_attr( $structures[3] ); ?>" <?php checked( $structures[3], $permalink_structure ); ?> /> <?php _e( 'Numeric' ); ?></label></th>

View File

@ -37,12 +37,12 @@ class IXR_Date {
function parseTimestamp($timestamp)
{
$this->year = date('Y', $timestamp);
$this->month = date('m', $timestamp);
$this->day = date('d', $timestamp);
$this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp);
$this->year = gmdate('Y', $timestamp);
$this->month = gmdate('m', $timestamp);
$this->day = gmdate('d', $timestamp);
$this->hour = gmdate('H', $timestamp);
$this->minute = gmdate('i', $timestamp);
$this->second = gmdate('s', $timestamp);
$this->timezone = '';
}

View File

@ -151,7 +151,7 @@ EOD;
header('Content-Type: text/xml; charset='.$charset);
else
header('Content-Type: text/xml');
header('Date: '.date('r'));
header('Date: '.gmdate('r'));
echo $xml;
exit;
}

View File

@ -87,7 +87,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
$title .= ' (';
$title .= sprintf(
__( 'Last updated: %s' ),
date(
gmdate(
get_option( 'links_updated_date_format' ),
$bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
)

View File

@ -443,7 +443,7 @@ class WP {
}
if ( ! $wp_last_modified ) {
$wp_last_modified = date( 'D, d M Y H:i:s' );
$wp_last_modified = gmdate( 'D, d M Y H:i:s' );
}
$wp_last_modified .= ' GMT';

View File

@ -337,7 +337,7 @@ function get_lastcommentmodified( $timezone = 'server' ) {
$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
break;
case 'server':
$add_seconds_server = date( 'Z' );
$add_seconds_server = gmdate( 'Z' );
$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
break;

View File

@ -317,7 +317,7 @@ class WP_Date_Query {
$_year = $date_query['year'];
}
$max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
$max_days_of_year = gmdate( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
} else {
// otherwise we use the max of 366 (leap-year)
$max_days_of_year = 366;
@ -352,7 +352,7 @@ class WP_Date_Query {
* If we have a specific year, use it to calculate number of weeks.
* Note: the number of weeks in a year is the date in which Dec 28 appears.
*/
$week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
$week_count = gmdate( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
} else {
// Otherwise set the week-count to a maximum of 53.
@ -923,7 +923,7 @@ class WP_Date_Query {
}
if ( ! isset( $datetime['day'] ) ) {
$datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
$datetime['day'] = ( $default_to_max ) ? (int) gmdate( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
}
if ( ! isset( $datetime['hour'] ) ) {

View File

@ -960,7 +960,7 @@ function get_links($category = -1, $before = '', $after = '<br />', $between = '
if ( $show_updated )
if (substr($row->link_updated_f, 0, 2) != '00')
$title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
$title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
if ( '' != $title )
$title = ' title="' . $title . '"';

View File

@ -3432,13 +3432,13 @@ function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) {
if ( $tz ) {
$datetime = date_create( $string, new DateTimeZone( 'UTC' ) );
if ( ! $datetime ) {
return date( $format, 0 );
return gmdate( $format, 0 );
}
$datetime->setTimezone( new DateTimeZone( $tz ) );
$string_localtime = $datetime->format( $format );
} else {
if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) {
return date( $format, 0 );
return gmdate( $format, 0 );
}
$string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
$string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );

View File

@ -41,7 +41,7 @@ function mysql2date( $format, $date, $translate = true ) {
if ( $translate ) {
return date_i18n( $format, $i );
} else {
return date( $format, $i );
return gmdate( $format, $i );
}
}
@ -111,12 +111,12 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa
$dateformatstring = preg_replace( '/(?<!\\\\)r/', DATE_RFC2822, $dateformatstring );
if ( ( ! empty( $wp_locale->month ) ) && ( ! empty( $wp_locale->weekday ) ) ) {
$datemonth = $wp_locale->get_month( date( 'm', $i ) );
$datemonth = $wp_locale->get_month( gmdate( 'm', $i ) );
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
$dateweekday = $wp_locale->get_weekday( date( 'w', $i ) );
$dateweekday = $wp_locale->get_weekday( gmdate( 'w', $i ) );
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
$datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) );
$datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) );
$datemeridiem = $wp_locale->get_meridiem( gmdate( 'a', $i ) );
$datemeridiem_capital = $wp_locale->get_meridiem( gmdate( 'A', $i ) );
$dateformatstring = ' ' . $dateformatstring;
$dateformatstring = preg_replace( '/([^\\\])D/', "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
$dateformatstring = preg_replace( '/([^\\\])F/', "\\1" . backslashit( $datemonth ), $dateformatstring );
@ -177,7 +177,7 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa
}
}
}
$j = @date( $dateformatstring, $i );
$j = @gmdate( $dateformatstring, $i );
/**
* Filters the date formatted based on the locale.
@ -415,7 +415,7 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
$day = mktime( 0, 0, 0, $md, $mm, $my );
// The day of the week from the timestamp.
$weekday = date( 'w', $day );
$weekday = gmdate( 'w', $day );
if ( ! is_numeric( $start_of_week ) ) {
$start_of_week = get_option( 'start_of_week' );

View File

@ -2107,7 +2107,7 @@ function get_calendar( $initial = true, $echo = true ) {
}
$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
$last_day = date( 't', $unixmonth );
$last_day = gmdate( 't', $unixmonth );
// Get the next and previous month and year with at least one post
$previous = $wpdb->get_row(
@ -2133,7 +2133,7 @@ function get_calendar( $initial = true, $echo = true ) {
<caption>' . sprintf(
$calendar_caption,
$wp_locale->get_month( $thismonth ),
date( 'Y', $unixmonth )
gmdate( 'Y', $unixmonth )
) . '</caption>
<thead>
<tr>';
@ -2199,13 +2199,13 @@ function get_calendar( $initial = true, $echo = true ) {
}
// See how much we should pad in the beginning
$pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
$pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins );
if ( 0 != $pad ) {
$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">&nbsp;</td>';
}
$newrow = false;
$daysinmonth = (int) date( 't', $unixmonth );
$daysinmonth = (int) gmdate( 't', $unixmonth );
for ( $day = 1; $day <= $daysinmonth; ++$day ) {
if ( isset( $newrow ) && $newrow ) {
@ -2223,7 +2223,7 @@ function get_calendar( $initial = true, $echo = true ) {
if ( in_array( $day, $daywithpost ) ) {
// any posts today?
$date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
$date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
/* translators: Post calendar label. %s: Date */
$label = sprintf( __( 'Posts published on %s' ), $date_format );
$calendar_output .= sprintf(
@ -2237,12 +2237,12 @@ function get_calendar( $initial = true, $echo = true ) {
}
$calendar_output .= '</td>';
if ( 6 == calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
$newrow = true;
}
}
$pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
$pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
if ( $pad != 0 && $pad != 7 ) {
$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
}
@ -4452,7 +4452,7 @@ function get_the_generator( $type = '' ) {
$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo( 'version' ) ) . '" -->';
break;
case 'export':
$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . date( 'Y-m-d H:i' ) . '" -->';
$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . gmdate( 'Y-m-d H:i' ) . '" -->';
break;
}

View File

@ -212,7 +212,7 @@ function get_permalink( $post = 0, $leavename = false ) {
$author = $authordata->user_nicename;
}
$date = explode( ' ', date( 'Y m d H i s', $unixtime ) );
$date = explode( ' ', gmdate( 'Y m d H i s', $unixtime ) );
$rewritereplace =
array(
$date[0],

View File

@ -6031,8 +6031,8 @@ function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
* @param WP_Post $post_before The Previous Post Object
*/
function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
$previous_date = date( 'Y-m-d', strtotime( $post_before->post_date ) );
$new_date = date( 'Y-m-d', strtotime( $post->post_date ) );
$previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
$new_date = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
// Don't bother if it hasn't changed.
if ( $new_date == $previous_date ) {
return;
@ -6286,7 +6286,7 @@ function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
$date = $wpdb->get_var( "SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" );
break;
case 'server':
$add_seconds_server = date( 'Z' );
$add_seconds_server = gmdate( 'Z' );
$date = $wpdb->get_var( "SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" );
break;
}

View File

@ -924,10 +924,10 @@ function rest_get_date_with_gmt( $date, $is_utc = false ) {
// Timezone conversion needs to be handled differently between these two
// cases.
if ( ! $is_utc && ! $has_timezone ) {
$local = date( 'Y-m-d H:i:s', $date );
$local = gmdate( 'Y-m-d H:i:s', $date );
$utc = get_gmt_from_date( $local );
} else {
$utc = date( 'Y-m-d H:i:s', $date );
$utc = gmdate( 'Y-m-d H:i:s', $date );
$local = get_date_from_gmt( $utc );
}

View File

@ -1478,7 +1478,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
// based on the `post_modified` field with the site's timezone
// offset applied.
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 ) );
} else {
$post_modified_gmt = $post->post_modified_gmt;
}

View File

@ -925,7 +925,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
}
if ( in_array( 'registered_date', $fields, true ) ) {
$data['registered_date'] = date( 'c', strtotime( $user->user_registered ) );
$data['registered_date'] = gmdate( 'c', strtotime( $user->user_registered ) );
}
if ( in_array( 'capabilities', $fields, true ) ) {

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 ),
)
);
}