WordPress.org

Make WordPress Core

Changeset 48920


Ignore:
Timestamp:
08/31/2020 06:53:52 PM (3 months ago)
Author:
desrosj
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.
Merges [48911] to the 5.5 branch.
See #51184.

Location:
branches/5.5
Files:
1 deleted
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/tests/phpunit/tests/date/mysql2date.php

    r47118 r48920  
    1212
    1313        parent::tearDown();
     14    }
     15
     16    /**
     17     * @ticket 28310
     18     */
     19    function test_mysql2date_returns_false_with_no_date() {
     20        $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) );
     21    }
     22
     23    /**
     24     * @ticket 28310
     25     */
     26    function test_mysql2date_returns_gmt_or_unix_timestamp() {
     27        $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) );
     28        $this->assertEquals( '441013392', mysql2date( 'U', '1983-12-23 07:43:12' ) );
    1429    }
    1530
  • branches/5.5/tests/phpunit/tests/date/theDate.php

    r46586 r48920  
    44 * @group date
    55 * @group datetime
     6 * @group post
    67 */
    78class Tests_Date_The_Date extends WP_UnitTestCase {
  • branches/5.5/tests/phpunit/tests/post.php

    r48497 r48920  
    897897
    898898    /**
    899      * @ticket 13771
    900      */
    901     function test_get_the_date_with_id_returns_correct_time() {
    902         $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    903         $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
    904     }
    905 
    906     /**
    907      * @ticket 28310
    908      */
    909     function test_get_the_date_returns_false_with_null_or_non_existing_post() {
    910         $this->assertFalse( get_the_date() );
    911         $this->assertFalse( get_the_date( 'F j, Y h:i:s' ) );
    912         $this->assertFalse( get_the_date( '', 9 ) );
    913         $this->assertFalse( get_the_date( 'F j, Y h:i:s', 9 ) );
    914     }
    915 
    916     /**
    917      * @ticket 28310
    918      */
    919     function test_get_the_time_with_id_returns_correct_time() {
    920         $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    921         $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) );
    922     }
    923 
    924     /**
    925      * @ticket 28310
    926      */
    927     function test_get_the_time_returns_false_with_null_or_non_existing_post() {
    928         $this->assertFalse( get_the_time() );
    929         $this->assertFalse( get_the_time( 'h:i:s' ) );
    930         $this->assertFalse( get_the_time( '', 9 ) );
    931         $this->assertFalse( get_the_time( 'h:i:s', 9 ) );
    932     }
    933 
    934     /**
    935      * @ticket 28310
    936      */
    937     function test_get_post_time_with_id_returns_correct_time() {
    938         $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    939         $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
    940     }
    941 
    942     /**
    943      * @ticket 28310
    944      */
    945     function test_get_post_time_returns_false_with_null_or_non_existing_post() {
    946         $this->assertFalse( get_post_time() );
    947         $this->assertFalse( get_post_time( 'h:i:s' ) );
    948         $this->assertFalse( get_post_time( '', false, 9 ) );
    949         $this->assertFalse( get_post_time( 'h:i:s', false, 9 ) );
    950     }
    951 
    952     /**
    953      * @ticket 28310
    954      */
    955     function test_get_post_modified_time_with_id_returns_correct_time() {
    956         $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
    957         $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
    958     }
    959 
    960     /**
    961      * @ticket 28310
    962      */
    963     function test_get_post_modified_time_returns_false_with_null_or_non_existing_post() {
    964         $this->assertFalse( get_post_modified_time() );
    965         $this->assertFalse( get_post_modified_time( 'h:i:s' ) );
    966         $this->assertFalse( get_post_modified_time( '', false, 9 ) );
    967         $this->assertFalse( get_post_modified_time( 'h:i:s', false, 9 ) );
    968     }
    969 
    970     /**
    971      * @ticket 28310
    972      */
    973     function test_mysql2date_returns_false_with_no_date() {
    974         $this->assertFalse( mysql2date( 'F j, Y H:i:s', '' ) );
    975     }
    976 
    977     /**
    978      * @ticket 28310
    979      */
    980     function test_mysql2date_returns_gmt_or_unix_timestamp() {
    981         $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) );
    982         $this->assertEquals( '441013392', mysql2date( 'U', '1983-12-23 07:43:12' ) );
    983     }
    984 
    985     /**
    986899     * @ticket 25566
    987900     */
Note: See TracChangeset for help on using the changeset viewer.