Make WordPress Core

Changeset 48633


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

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

Follow-up to [48631].

Props munyagu.
See #47777.

Location:
trunk/tests/phpunit/tests/post
Files:
2 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}
  • trunk/tests/phpunit/tests/post/getLastPostModified.php

    r48631 r48633  
    1212                global $wpdb;
    1313
    14                 $post_post_date     = '2020-01-30 16:09:28';
    15                 $post_post_modified = '2020-02-28 17:10:29';
     14                $post_post_date_first     = '2020-01-30 16:09:28';
     15                $post_post_modified_first = '2020-02-28 17:10:29';
     16                $post_post_date_last      = '2020-03-30 18:11:30';
     17                $post_post_modified_last  = '2020-04-30 19:12:31';
    1618
    17                 $book_post_date     = '2019-03-30 20:09:28';
    18                 $book_post_modified = '2019-04-30 21:10:29';
     19                $book_post_date_first     = '2019-05-30 20:09:28';
     20                $book_post_modified_first = '2019-06-30 21:10:29';
     21                $book_post_date_last      = '2019-07-30 22:11:30';
     22                $book_post_modified_last  = '2019-08-30 23:12:31';
    1923
    2024                // Register book post type.
    … …  
    2226
    2327                // Create a simple post.
    24                 $simple_post_id = self::factory()->post->create(
     28                $simple_post_id_first = self::factory()->post->create(
    2529                        array(
    26                                 'post_title' => 'Simple Post',
     30                                'post_title' => 'Simple Post First',
    2731                                'post_type'  => 'post',
    28                                 'post_date'  => $post_post_date,
     32                                'post_date'  => $post_post_date_first,
     33                        )
     34                );
     35
     36                $simple_post_id_last = self::factory()->post->create(
     37                        array(
     38                                'post_title' => 'Simple Post Last',
     39                                'post_type'  => 'post',
     40                                'post_date'  => $post_post_date_last,
    2941                        )
    3042                );
    3143
    3244                // Create custom type post.
    33                 $book_cpt_id = self::factory()->post->create(
     45                $book_cpt_id_first = self::factory()->post->create(
    3446                        array(
    35                                 'post_title' => 'Book CPT',
     47                                'post_title' => 'Book CPT First',
    3648                                'post_type'  => 'book',
    37                                 'post_date'  => $book_post_date,
     49                                'post_date'  => $book_post_date_first,
     50                        )
     51                );
     52
     53                $book_cpt_id_last = self::factory()->post->create(
     54                        array(
     55                                'post_title' => 'Book CPT Last',
     56                                'post_type'  => 'book',
     57                                'post_date'  => $book_post_date_last,
    3858                        )
    3959                );
    … …  
    4363                        $wpdb->posts,
    4464                        array(
    45                                 'post_modified'     => $post_post_modified,
    46                                 'post_modified_gmt' => $post_post_modified,
     65                                'post_modified'     => $post_post_modified_first,
     66                                'post_modified_gmt' => $post_post_modified_first,
    4767                        ),
    4868                        array(
    49                                 'ID' => $simple_post_id,
     69                                'ID' => $simple_post_id_first,
    5070                        )
    5171                );
    … …  
    5474                        $wpdb->posts,
    5575                        array(
    56                                 'post_modified'     => $book_post_modified,
    57                                 'post_modified_gmt' => $book_post_modified,
     76                                'post_modified'     => $post_post_modified_last,
     77                                'post_modified_gmt' => $post_post_modified_last,
    5878                        ),
    5979                        array(
    60                                 'ID' => $book_cpt_id,
     80                                'ID' => $simple_post_id_last,
    6181                        )
    6282                );
    6383
    64                 $this->assertEquals( $post_post_modified, get_lastpostmodified( 'blog', 'post' ) );
    65                 $this->assertEquals( $book_post_modified, get_lastpostmodified( 'blog', 'book' ) );
     84                $wpdb->update(
     85                        $wpdb->posts,
     86                        array(
     87                                'post_modified'     => $book_post_modified_first,
     88                                'post_modified_gmt' => $book_post_modified_first,
     89                        ),
     90                        array(
     91                                'ID' => $book_cpt_id_first,
     92                        )
     93                );
     94
     95                $wpdb->update(
     96                        $wpdb->posts,
     97                        array(
     98                                'post_modified'     => $book_post_modified_last,
     99                                'post_modified_gmt' => $book_post_modified_last,
     100                        ),
     101                        array(
     102                                'ID' => $book_cpt_id_last,
     103                        )
     104                );
     105
     106                $this->assertEquals( $post_post_modified_last, get_lastpostmodified( 'blog', 'post' ) );
     107                $this->assertEquals( $book_post_modified_last, get_lastpostmodified( 'blog', 'book' ) );
    66108        }
    67109}
Note: See TracChangeset for help on using the changeset viewer.