Make WordPress Core


Ignore:
Timestamp:
08/31/2020 03:33:45 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Bring some consistency to Date/Time tests:

  • Move some tests from post.php to a more appropriate location in the date directory.
  • Rename date/postTime.php to date/getPostTime.php to match the function name.

Props Rarst.
See #51184.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/date/getPostTime.php

    r48910 r48911  
    44 * @group date
    55 * @group datetime
     6 * @group post
    67 */
    7 class Tests_Date_Post_Time extends WP_UnitTestCase {
     8class Tests_Date_Get_Post_Time extends WP_UnitTestCase {
     9
     10        /**
     11         * @ticket 28310
     12         */
     13        public function test_get_post_time_with_id_returns_correct_time() {
     14                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     15                $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
     16        }
     17
     18        /**
     19         * @ticket 28310
     20         */
     21        public function test_get_post_time_returns_false_with_null_or_non_existing_post() {
     22                $this->assertFalse( get_post_time() );
     23                $this->assertFalse( get_post_time( 'h:i:s' ) );
     24                $this->assertFalse( get_post_time( '', false, 9 ) );
     25                $this->assertFalse( get_post_time( 'h:i:s', false, 9 ) );
     26        }
     27
     28        /**
     29         * @ticket 28310
     30         */
     31        public function test_get_post_modified_time_with_id_returns_correct_time() {
     32                $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     33                $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
     34        }
     35
     36        /**
     37         * @ticket 28310
     38         */
     39        public function test_get_post_modified_time_returns_false_with_null_or_non_existing_post() {
     40                $this->assertFalse( get_post_modified_time() );
     41                $this->assertFalse( get_post_modified_time( 'h:i:s' ) );
     42                $this->assertFalse( get_post_modified_time( '', false, 9 ) );
     43                $this->assertFalse( get_post_modified_time( 'h:i:s', false, 9 ) );
     44        }
    845
    946        /**
Note: See TracChangeset for help on using the changeset viewer.