diff --git a/tests/phpunit/tests/date/postTime.php b/tests/phpunit/tests/date/getPostTime.php similarity index 70% rename from tests/phpunit/tests/date/postTime.php rename to tests/phpunit/tests/date/getPostTime.php index 1380c48160..c28add1450 100644 --- a/tests/phpunit/tests/date/postTime.php +++ b/tests/phpunit/tests/date/getPostTime.php @@ -3,8 +3,45 @@ /** * @group date * @group datetime + * @group post */ -class Tests_Date_Post_Time extends WP_UnitTestCase { +class Tests_Date_Get_Post_Time extends WP_UnitTestCase { + + /** + * @ticket 28310 + */ + public function test_get_post_time_with_id_returns_correct_time() { + $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); + } + + /** + * @ticket 28310 + */ + public function test_get_post_time_returns_false_with_null_or_non_existing_post() { + $this->assertFalse( get_post_time() ); + $this->assertFalse( get_post_time( 'h:i:s' ) ); + $this->assertFalse( get_post_time( '', false, 9 ) ); + $this->assertFalse( get_post_time( 'h:i:s', false, 9 ) ); + } + + /** + * @ticket 28310 + */ + public function test_get_post_modified_time_with_id_returns_correct_time() { + $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); + } + + /** + * @ticket 28310 + */ + public function test_get_post_modified_time_returns_false_with_null_or_non_existing_post() { + $this->assertFalse( get_post_modified_time() ); + $this->assertFalse( get_post_modified_time( 'h:i:s' ) ); + $this->assertFalse( get_post_modified_time( '', false, 9 ) ); + $this->assertFalse( get_post_modified_time( 'h:i:s', false, 9 ) ); + } /** * @ticket 25002 diff --git a/tests/phpunit/tests/date/getTheDate.php b/tests/phpunit/tests/date/getTheDate.php new file mode 100644 index 0000000000..03248dba5f --- /dev/null +++ b/tests/phpunit/tests/date/getTheDate.php @@ -0,0 +1,45 @@ +post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); + } + + /** + * @ticket 28310 + */ + function test_get_the_date_returns_false_with_null_or_non_existing_post() { + $this->assertFalse( get_the_date() ); + $this->assertFalse( get_the_date( 'F j, Y h:i:s' ) ); + $this->assertFalse( get_the_date( '', 9 ) ); + $this->assertFalse( get_the_date( 'F j, Y h:i:s', 9 ) ); + } + + /** + * @ticket 28310 + */ + function test_get_the_time_with_id_returns_correct_time() { + $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); + $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); + } + + /** + * @ticket 28310 + */ + function test_get_the_time_returns_false_with_null_or_non_existing_post() { + $this->assertFalse( get_the_time() ); + $this->assertFalse( get_the_time( 'h:i:s' ) ); + $this->assertFalse( get_the_time( '', 9 ) ); + $this->assertFalse( get_the_time( 'h:i:s', 9 ) ); + } +} diff --git a/tests/phpunit/tests/date/mysql2date.php b/tests/phpunit/tests/date/mysql2date.php index 25b0784e26..863f812d89 100644 --- a/tests/phpunit/tests/date/mysql2date.php +++ b/tests/phpunit/tests/date/mysql2date.php @@ -13,6 +13,21 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { parent::tearDown(); } + /** + * @ticket 28310 + */ + function test_mysql2date_returns_false_with_no_date() { + $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) ); + } + + /** + * @ticket 28310 + */ + function test_mysql2date_returns_gmt_or_unix_timestamp() { + $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) ); + $this->assertEquals( '441013392', mysql2date( 'U', '1983-12-23 07:43:12' ) ); + } + /** * @ticket 28992 */ diff --git a/tests/phpunit/tests/date/theDate.php b/tests/phpunit/tests/date/theDate.php index 2542240d6b..46fff6709e 100644 --- a/tests/phpunit/tests/date/theDate.php +++ b/tests/phpunit/tests/date/theDate.php @@ -3,6 +3,7 @@ /** * @group date * @group datetime + * @group post */ class Tests_Date_The_Date extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 14cfb31d16..3b5af7bad4 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -895,93 +895,6 @@ class Tests_Post extends WP_UnitTestCase { $this->assertEquals( 0, $counts->test ); } - /** - * @ticket 13771 - */ - function test_get_the_date_with_id_returns_correct_time() { - $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); - } - - /** - * @ticket 28310 - */ - function test_get_the_date_returns_false_with_null_or_non_existing_post() { - $this->assertFalse( get_the_date() ); - $this->assertFalse( get_the_date( 'F j, Y h:i:s' ) ); - $this->assertFalse( get_the_date( '', 9 ) ); - $this->assertFalse( get_the_date( 'F j, Y h:i:s', 9 ) ); - } - - /** - * @ticket 28310 - */ - function test_get_the_time_with_id_returns_correct_time() { - $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); - } - - /** - * @ticket 28310 - */ - function test_get_the_time_returns_false_with_null_or_non_existing_post() { - $this->assertFalse( get_the_time() ); - $this->assertFalse( get_the_time( 'h:i:s' ) ); - $this->assertFalse( get_the_time( '', 9 ) ); - $this->assertFalse( get_the_time( 'h:i:s', 9 ) ); - } - - /** - * @ticket 28310 - */ - function test_get_post_time_with_id_returns_correct_time() { - $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); - } - - /** - * @ticket 28310 - */ - function test_get_post_time_returns_false_with_null_or_non_existing_post() { - $this->assertFalse( get_post_time() ); - $this->assertFalse( get_post_time( 'h:i:s' ) ); - $this->assertFalse( get_post_time( '', false, 9 ) ); - $this->assertFalse( get_post_time( 'h:i:s', false, 9 ) ); - } - - /** - * @ticket 28310 - */ - function test_get_post_modified_time_with_id_returns_correct_time() { - $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); - } - - /** - * @ticket 28310 - */ - function test_get_post_modified_time_returns_false_with_null_or_non_existing_post() { - $this->assertFalse( get_post_modified_time() ); - $this->assertFalse( get_post_modified_time( 'h:i:s' ) ); - $this->assertFalse( get_post_modified_time( '', false, 9 ) ); - $this->assertFalse( get_post_modified_time( 'h:i:s', false, 9 ) ); - } - - /** - * @ticket 28310 - */ - function test_mysql2date_returns_false_with_no_date() { - $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) ); - } - - /** - * @ticket 28310 - */ - function test_mysql2date_returns_gmt_or_unix_timestamp() { - $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) ); - $this->assertEquals( '441013392', mysql2date( 'U', '1983-12-23 07:43:12' ) ); - } - /** * @ticket 25566 */