Skip to content

Commit 3f6b7e9

Browse files
Abilities API: Use a winter date in the content update ability tests.
The floating draft tests used a date in June 2099 in a time zone with daylight saving time. PHP versions before 8.1 apply no daylight saving time after 2037, so the expected GMT date was one hour off on PHP 7.4 and 8.0.
1 parent 5481e36 commit 3f6b7e9

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

‎tests/phpunit/tests/abilities-api/wpRegisterCoreContentUpdateAbility.php‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ public function test_draft_page_slug_is_unique_among_its_siblings( string $paren
18761876
*/
18771877
public function test_update_without_a_date_keeps_a_draft_floating(): void {
18781878
update_option( 'timezone_string', 'America/New_York' );
1879-
$post_id = $this->create_floating_draft( '2099-06-15 10:00:00' );
1879+
$post_id = $this->create_floating_draft( '2099-01-15 10:00:00' );
18801880

18811881
$this->login_as( 'editor' );
18821882
$this->register_abilities();
@@ -1930,7 +1930,7 @@ public function test_publishing_a_floating_draft_without_a_date_stamps_the_curre
19301930
*/
19311931
public function test_pending_without_a_date_keeps_a_draft_floating(): void {
19321932
update_option( 'timezone_string', 'America/New_York' );
1933-
$post_id = $this->create_floating_draft( '2099-06-15 10:00:00' );
1933+
$post_id = $this->create_floating_draft( '2099-01-15 10:00:00' );
19341934

19351935
$this->login_as( 'editor' );
19361936
$this->register_abilities();
@@ -2012,7 +2012,7 @@ public static function data_new_dates_for_a_floating_draft(): array {
20122012
*/
20132013
public function test_new_date_pins_a_floating_draft( array $date ): void {
20142014
update_option( 'timezone_string', 'America/New_York' );
2015-
$post_id = $this->create_floating_draft( '2099-06-15 10:00:00' );
2015+
$post_id = $this->create_floating_draft( '2099-01-15 10:00:00' );
20162016

20172017
$this->login_as( 'editor' );
20182018
$this->register_abilities();
@@ -2025,14 +2025,17 @@ public function test_new_date_pins_a_floating_draft( array $date ): void {
20252025
}
20262026

20272027
/**
2028-
* Returns dates equal to the date a floating draft shows, 2099-06-15 10:00 in America/New_York.
2028+
* Returns dates equal to the date a floating draft shows, 2099-01-15 10:00 in America/New_York.
2029+
*
2030+
* The date is in winter because PHP versions before 8.1 apply no daylight saving time
2031+
* after 2037.
20292032
*
20302033
* @return array<string, array{date: array<string, string>}> The dates.
20312034
*/
20322035
public static function data_dates_equal_to_the_floating_date(): array {
20332036
return array(
2034-
'site' => array( array( 'site' => '2099-06-15T10:00:00' ) ),
2035-
'gmt' => array( array( 'gmt' => '2099-06-15T14:00:00' ) ),
2037+
'site' => array( array( 'site' => '2099-01-15T10:00:00' ) ),
2038+
'gmt' => array( array( 'gmt' => '2099-01-15T15:00:00' ) ),
20362039
);
20372040
}
20382041

@@ -2047,7 +2050,7 @@ public static function data_dates_equal_to_the_floating_date(): array {
20472050
*/
20482051
public function test_date_equal_to_the_floating_date_does_not_pin_the_draft( array $date ): void {
20492052
update_option( 'timezone_string', 'America/New_York' );
2050-
$post_id = $this->create_floating_draft( '2099-06-15 10:00:00' );
2053+
$post_id = $this->create_floating_draft( '2099-01-15 10:00:00' );
20512054

20522055
$this->login_as( 'editor' );
20532056
$this->register_abilities();
@@ -2127,8 +2130,8 @@ public function test_date_equal_to_the_stored_date_changes_nothing( array $date
21272130
array(
21282131
'post_author' => self::$user_ids['editor'],
21292132
'post_status' => 'future',
2130-
'post_date' => '2099-06-15 10:00:00',
2131-
'post_date_gmt' => '2099-06-15 14:00:00',
2133+
'post_date' => '2099-01-15 10:00:00',
2134+
'post_date_gmt' => '2099-01-15 15:00:00',
21322135
)
21332136
);
21342137

@@ -2138,8 +2141,8 @@ public function test_date_equal_to_the_stored_date_changes_nothing( array $date
21382141
$post = $this->assert_updated( $this->update_post( $post_id, array( 'date' => $date ) ), $post_id );
21392142

21402143
$this->assertSame( 'future', $post->post_status, 'The post should stay scheduled.' );
2141-
$this->assertSame( '2099-06-15 10:00:00', $post->post_date, 'The local date should not change.' );
2142-
$this->assertSame( '2099-06-15 14:00:00', $post->post_date_gmt, 'The GMT date should not change.' );
2144+
$this->assertSame( '2099-01-15 10:00:00', $post->post_date, 'The local date should not change.' );
2145+
$this->assertSame( '2099-01-15 15:00:00', $post->post_date_gmt, 'The GMT date should not change.' );
21432146
}
21442147

21452148
/**
@@ -2149,10 +2152,10 @@ public function test_date_equal_to_the_stored_date_changes_nothing( array $date
21492152
*/
21502153
public static function data_schedules_a_floating_draft_for_the_date_it_shows(): array {
21512154
return array(
2152-
'future, site' => array( 'future', array( 'site' => '2099-06-15T10:00:00' ) ),
2153-
'future, gmt' => array( 'future', array( 'gmt' => '2099-06-15T14:00:00' ) ),
2154-
'publish, site' => array( 'publish', array( 'site' => '2099-06-15T10:00:00' ) ),
2155-
'publish, gmt' => array( 'publish', array( 'gmt' => '2099-06-15T14:00:00' ) ),
2155+
'future, site' => array( 'future', array( 'site' => '2099-01-15T10:00:00' ) ),
2156+
'future, gmt' => array( 'future', array( 'gmt' => '2099-01-15T15:00:00' ) ),
2157+
'publish, site' => array( 'publish', array( 'site' => '2099-01-15T10:00:00' ) ),
2158+
'publish, gmt' => array( 'publish', array( 'gmt' => '2099-01-15T15:00:00' ) ),
21562159
);
21572160
}
21582161

@@ -2168,7 +2171,7 @@ public static function data_schedules_a_floating_draft_for_the_date_it_shows():
21682171
*/
21692172
public function test_scheduling_a_floating_draft_for_the_date_it_shows( string $status, array $date ): void {
21702173
update_option( 'timezone_string', 'America/New_York' );
2171-
$post_id = $this->create_floating_draft( '2099-06-15 10:00:00' );
2174+
$post_id = $this->create_floating_draft( '2099-01-15 10:00:00' );
21722175

21732176
$this->login_as( 'editor' );
21742177
$this->register_abilities();
@@ -2184,8 +2187,8 @@ public function test_scheduling_a_floating_draft_for_the_date_it_shows( string $
21842187
$post = $this->assert_updated( $result, $post_id );
21852188

21862189
$this->assertSame( 'future', $post->post_status, 'The post should be scheduled.' );
2187-
$this->assertSame( '2099-06-15 10:00:00', $post->post_date, 'The local date should be the sent date.' );
2188-
$this->assertSame( '2099-06-15 14:00:00', $post->post_date_gmt, 'The GMT date should be the sent date.' );
2190+
$this->assertSame( '2099-01-15 10:00:00', $post->post_date, 'The local date should be the sent date.' );
2191+
$this->assertSame( '2099-01-15 15:00:00', $post->post_date_gmt, 'The GMT date should be the sent date.' );
21892192
$this->assertSame( 'future', $result['status'], 'The scheduled status should be returned.' );
21902193
}
21912194

0 commit comments

Comments
 (0)