mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
The `options` table is not explicitly reset after each test or test class, so if an option is changed during a test, it should be reset to the default value ''after'' the test. This commit does so for those tests which did not have such resetting in place yet, while one or more tests in the class ''do'' change the value of the `timezone_string` option. Note: The test suite executes a `ROLLBACK` query after each test, which should reset the `options` table in theory, however that appears to not always be enough, as some timezone-related tests can fail in a complete test suite run, while not failing when run in isolation. This commit aims to improve stability of the tests. Follow-up to [45857] / #45821. Props jrf, costdev. See #56468. git-svn-id: https://develop.svn.wordpress.org/trunk@54207 602fd350-edb4-49c9-b593-d223f7449a82
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group date
|
|
* @group datetime
|
|
* @group post
|
|
* @covers ::get_permalink
|
|
*/
|
|
class Tests_Date_GetPermalink extends WP_UnitTestCase {
|
|
|
|
public function tear_down() {
|
|
delete_option( 'permalink_structure' );
|
|
update_option( 'timezone_string', '' );
|
|
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
|
date_default_timezone_set( 'UTC' );
|
|
|
|
parent::tear_down();
|
|
}
|
|
|
|
/**
|
|
* @ticket 48623
|
|
*/
|
|
public function test_should_return_correct_date_permalink_with_changed_time_zone() {
|
|
$timezone = 'America/Chicago';
|
|
update_option( 'timezone_string', $timezone );
|
|
update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%hour%/%minute%/%second%' );
|
|
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
|
date_default_timezone_set( 'UTC' );
|
|
|
|
$post_id = self::factory()->post->create(
|
|
array(
|
|
'post_date' => '2018-07-22 21:13:23',
|
|
'post_date_gmt' => '2018-07-23 03:13:23',
|
|
)
|
|
);
|
|
|
|
$this->assertSame( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
|
|
|
|
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
|
|
date_default_timezone_set( $timezone );
|
|
$this->assertSame( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
|
|
}
|
|
}
|