WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/27/2020 11:15:04 AM (16 months ago)
Author:
SergeyBiryukov
Message:

Tests: Add more fixtures to get_lastpostdate() and get_lastpostmodified() tests.

Follow-up to [48631].

Props munyagu.
See #47777.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getLastPostDate.php

    r48631 r48633  
    1010     */
    1111    public function test_get_lastpostdate() {
    12         $post_post_date = '2020-01-30 16:09:28';
    13         $book_post_date = '2019-02-28 18:11:30';
     12        $post_post_date_first = '2020-01-30 16:09:28';
     13        $post_post_date_last  = '2020-02-28 16:09:28';
     14
     15        $book_post_date_first = '2019-03-30 18:11:30';
     16        $book_post_date_last  = '2019-04-30 18:11:30';
    1417
    1518        // Register book post type.
     
    1720
    1821        // Create a simple post.
    19         $simple_post_id = self::factory()->post->create(
     22        $simple_post_id_first = self::factory()->post->create(
    2023            array(
    21                 'post_title' => 'Simple Post',
     24                'post_title' => 'Simple Post First',
    2225                'post_type'  => 'post',
    23                 'post_date'  => $post_post_date,
     26                'post_date'  => $post_post_date_first,
     27            )
     28        );
     29
     30        $simple_post_id_last = self::factory()->post->create(
     31            array(
     32                'post_title' => 'Simple Post Last',
     33                'post_type'  => 'post',
     34                'post_date'  => $post_post_date_last,
    2435            )
    2536        );
    2637
    2738        // Create custom type post.
    28         $book_cpt_id = self::factory()->post->create(
     39        $book_cpt_id_first = self::factory()->post->create(
    2940            array(
    30                 'post_title' => 'Book CPT',
     41                'post_title' => 'Book CPT First',
    3142                'post_type'  => 'book',
    32                 'post_date'  => $book_post_date,
     43                'post_date'  => $book_post_date_first,
    3344            )
    3445        );
    3546
    36         $this->assertEquals( $post_post_date, get_lastpostdate( 'blog', 'post' ) );
    37         $this->assertEquals( $book_post_date, get_lastpostdate( 'blog', 'book' ) );
     47        $book_cpt_id_last = self::factory()->post->create(
     48            array(
     49                'post_title' => 'Book CPT Last',
     50                'post_type'  => 'book',
     51                'post_date'  => $book_post_date_last,
     52            )
     53        );
     54
     55        $this->assertEquals( $post_post_date_last, get_lastpostdate( 'blog', 'post' ) );
     56        $this->assertEquals( $book_post_date_last, get_lastpostdate( 'blog', 'book' ) );
    3857    }
    3958}
Note: See TracChangeset for help on using the changeset viewer.