Changeset 48633
- Timestamp:
- 07/27/2020 11:15:04 AM (6 years ago)
- Location:
- trunk/tests/phpunit/tests/post
- Files:
-
- 2 edited
-
getLastPostDate.php (modified) (2 diffs)
-
getLastPostModified.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getLastPostDate.php
r48631 r48633 10 10 */ 11 11 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'; 14 17 15 18 // Register book post type. … … 17 20 18 21 // Create a simple post. 19 $simple_post_id = self::factory()->post->create(22 $simple_post_id_first = self::factory()->post->create( 20 23 array( 21 'post_title' => 'Simple Post ',24 'post_title' => 'Simple Post First', 22 25 '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, 24 35 ) 25 36 ); 26 37 27 38 // Create custom type post. 28 $book_cpt_id = self::factory()->post->create(39 $book_cpt_id_first = self::factory()->post->create( 29 40 array( 30 'post_title' => 'Book CPT ',41 'post_title' => 'Book CPT First', 31 42 'post_type' => 'book', 32 'post_date' => $book_post_date ,43 'post_date' => $book_post_date_first, 33 44 ) 34 45 ); 35 46 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' ) ); 38 57 } 39 58 } -
trunk/tests/phpunit/tests/post/getLastPostModified.php
r48631 r48633 12 12 global $wpdb; 13 13 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'; 16 18 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'; 19 23 20 24 // Register book post type. … … 22 26 23 27 // Create a simple post. 24 $simple_post_id = self::factory()->post->create(28 $simple_post_id_first = self::factory()->post->create( 25 29 array( 26 'post_title' => 'Simple Post ',30 'post_title' => 'Simple Post First', 27 31 '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, 29 41 ) 30 42 ); 31 43 32 44 // Create custom type post. 33 $book_cpt_id = self::factory()->post->create(45 $book_cpt_id_first = self::factory()->post->create( 34 46 array( 35 'post_title' => 'Book CPT ',47 'post_title' => 'Book CPT First', 36 48 '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, 38 58 ) 39 59 ); … … 43 63 $wpdb->posts, 44 64 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, 47 67 ), 48 68 array( 49 'ID' => $simple_post_id ,69 'ID' => $simple_post_id_first, 50 70 ) 51 71 ); … … 54 74 $wpdb->posts, 55 75 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, 58 78 ), 59 79 array( 60 'ID' => $ book_cpt_id,80 'ID' => $simple_post_id_last, 61 81 ) 62 82 ); 63 83 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' ) ); 66 108 } 67 109 }
Note: See TracChangeset
for help on using the changeset viewer.