mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-02-27 11:12:50 +00:00
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650], [51651], [51860], [52264], [52265], [53489], [53863]. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54704 602fd350-edb4-49c9-b593-d223f7449a82
141 lines
4.1 KiB
PHP
141 lines
4.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group comment
|
|
* @ticket 38027
|
|
*
|
|
* @covers ::get_lastcommentmodified
|
|
*/
|
|
class Tests_Comment_GetLastCommentModified extends WP_UnitTestCase {
|
|
public function test_no_comments() {
|
|
$this->assertFalse( get_lastcommentmodified() );
|
|
}
|
|
|
|
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',
|
|
)
|
|
);
|
|
|
|
$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',
|
|
)
|
|
);
|
|
|
|
$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',
|
|
)
|
|
);
|
|
|
|
$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',
|
|
)
|
|
);
|
|
|
|
$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',
|
|
)
|
|
);
|
|
|
|
$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',
|
|
)
|
|
);
|
|
|
|
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',
|
|
)
|
|
);
|
|
|
|
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',
|
|
)
|
|
);
|
|
|
|
$this->assertFalse( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) );
|
|
$this->assertSame( strtotime( '2000-01-02 10:00:00' ), strtotime( get_lastcommentmodified() ) );
|
|
$this->assertSame( strtotime( '2000-01-02 10:00:00' ), strtotime( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) ) );
|
|
}
|
|
|
|
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_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();
|
|
|
|
$this->assertSame( strtotime( '2000-01-02 10:00:00' ), strtotime( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) ) );
|
|
|
|
wp_trash_comment( $comment_2->comment_ID );
|
|
|
|
$this->assertFalse( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) );
|
|
$this->assertSame( strtotime( '1998-01-01 10:00:00' ), strtotime( get_lastcommentmodified() ) );
|
|
$this->assertSame( strtotime( '1998-01-01 10:00:00' ), strtotime( wp_cache_get( 'lastcommentmodified:server', 'timeinfo' ) ) );
|
|
}
|
|
}
|