Code is Poetry.

WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2017-11-30 23:09:33 +00:00
parent ec6a089f98
commit 8f95800d52
1103 changed files with 105981 additions and 78187 deletions

View File

@@ -10,82 +10,98 @@ class Tests_Comment_Last_Modified extends WP_UnitTestCase {
}
public function test_default_timezone() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
)
);
$this->assertSame( strtotime( '2000-01-01 10:00:00' ), strtotime( get_lastcommentmodified() ) );
}
public function test_server_timezone() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
)
);
$this->assertSame( strtotime( '2000-01-01 10:00:00' ), strtotime( get_lastcommentmodified() ) );
}
public function test_blog_timezone() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
)
);
$this->assertSame( '2000-01-01 11:00:00', get_lastcommentmodified( 'blog' ) );
}
public function test_gmt_timezone() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
)
);
$this->assertSame( strtotime( '2000-01-01 10:00:00' ), strtotime( get_lastcommentmodified( 'GMT' ) ) );
}
public function test_unknown_timezone() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
)
);
$this->assertFalse( get_lastcommentmodified( 'foo' ) );
}
public function test_data_is_cached() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2015-04-01 11:00:00',
'comment_date_gmt' => '2015-04-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2015-04-01 11:00:00',
'comment_date_gmt' => '2015-04-01 10:00:00',
)
);
get_lastcommentmodified();
$this->assertSame( strtotime( '2015-04-01 10:00:00' ), strtotime( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) ) );
}
public function test_cache_is_cleared() {
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-01 11:00:00',
'comment_date_gmt' => '2000-01-01 10:00:00',
)
);
get_lastcommentmodified();
$this->assertSame( strtotime( '2000-01-01 10:00:00' ), strtotime( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) ) );
self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-02 11:00:00',
'comment_date_gmt' => '2000-01-02 10:00:00',
) );
self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-02 11:00:00',
'comment_date_gmt' => '2000-01-02 10:00:00',
)
);
$this->assertFalse( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) );
$this->assertSame( strtotime( '2000-01-02 10:00:00' ), strtotime( get_lastcommentmodified() ) );
@@ -93,17 +109,21 @@ class Tests_Comment_Last_Modified extends WP_UnitTestCase {
}
public function test_cache_is_cleared_when_comment_is_trashed() {
$comment_1 = self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '1998-01-01 11:00:00',
'comment_date_gmt' => '1998-01-01 10:00:00',
) );
$comment_1 = self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '1998-01-01 11:00:00',
'comment_date_gmt' => '1998-01-01 10:00:00',
)
);
$comment_2 = self::factory()->comment->create_and_get( array(
'comment_status' => 1,
'comment_date' => '2000-01-02 11:00:00',
'comment_date_gmt' => '2000-01-02 10:00:00',
) );
$comment_2 = self::factory()->comment->create_and_get(
array(
'comment_status' => 1,
'comment_date' => '2000-01-02 11:00:00',
'comment_date_gmt' => '2000-01-02 10:00:00',
)
);
get_lastcommentmodified();