Changeset 35225 for trunk/tests/phpunit/tests/comment/getPageOfComment.php
- Timestamp:
- 10/16/2015 09:04:12 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/getPageOfComment.php
r34828 r35225 8 8 9 9 public function test_last_comment() { 10 $p = $this->factory->post->create();10 $p = self::$factory->post->create(); 11 11 12 12 // page 4 13 $comment_last = $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) );14 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) );13 $comment_last = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-24 00:00:00' ) ); 14 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-23 00:00:00' ) ); 15 15 16 16 // page 3 17 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) );18 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) );19 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) );17 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-22 00:00:00' ) ); 18 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-21 00:00:00' ) ); 19 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-20 00:00:00' ) ); 20 20 21 21 // page 2 22 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) );23 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) );24 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) );22 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-19 00:00:00' ) ); 23 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-18 00:00:00' ) ); 24 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-17 00:00:00' ) ); 25 25 26 26 // page 1 27 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) );28 $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) );29 $comment_first = $this->factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) );27 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-16 00:00:00' ) ); 28 self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) ); 29 $comment_first = self::$factory->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) ); 30 30 31 31 $this->assertEquals( 4, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) ); … … 37 37 38 38 public function test_type_pings() { 39 $p = $this->factory->post->create();39 $p = self::$factory->post->create(); 40 40 $now = time(); 41 41 42 42 $trackbacks = array(); 43 43 for ( $i = 0; $i <= 3; $i++ ) { 44 $trackbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );44 $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); 45 45 $now -= 10 * $i; 46 46 } … … 48 48 $pingbacks = array(); 49 49 for ( $i = 0; $i <= 6; $i++ ) { 50 $pingbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );50 $pingbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'pingback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); 51 51 $now -= 10 * $i; 52 52 } … … 63 63 global $wpdb; 64 64 65 $p = $this->factory->post->create();66 $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) );65 $p = self::$factory->post->create(); 66 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); 67 67 68 68 // Prime cache. … … 82 82 global $wpdb; 83 83 84 $p = $this->factory->post->create();85 $comment = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) );84 $p = self::$factory->post->create(); 85 $comment = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'comment' ) ); 86 86 87 87 $now = time(); 88 88 $trackbacks = array(); 89 89 for ( $i = 0; $i <= 5; $i++ ) { 90 $trackbacks[ $i ] = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) );90 $trackbacks[ $i ] = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_type' => 'trackback', 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 10 * $i ) ) ) ); 91 91 } 92 92 … … 106 106 */ 107 107 public function test_cache_should_be_invalidated_when_comment_is_approved() { 108 $p = $this->factory->post->create();109 $c = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) );108 $p = self::$factory->post->create(); 109 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0 ) ); 110 110 111 111 // Prime cache. … … 122 122 */ 123 123 public function test_cache_should_be_invalidated_when_comment_is_deleted() { 124 $p = $this->factory->post->create();125 $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) );124 $p = self::$factory->post->create(); 125 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); 126 126 127 127 // Prime cache. … … 138 138 */ 139 139 public function test_cache_should_be_invalidated_when_comment_is_spammed() { 140 $p = $this->factory->post->create();141 $c = $this->factory->comment->create( array( 'comment_post_ID' => $p ) );140 $p = self::$factory->post->create(); 141 $c = self::$factory->comment->create( array( 'comment_post_ID' => $p ) ); 142 142 143 143 // Prime cache. … … 156 156 $now = time(); 157 157 158 $p = $this->factory->post->create();159 $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );160 $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );161 $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );158 $p = self::$factory->post->create(); 159 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); 160 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); 161 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => 0, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); 162 162 163 163 $this->assertEquals( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) ); … … 172 172 */ 173 173 public function test_query_should_be_limited_to_comments_on_the_proper_post() { 174 $posts = $this->factory->post->create_many( 2 );174 $posts = self::$factory->post->create_many( 2 ); 175 175 176 176 $now = time(); 177 177 $comments_0 = $comments_1 = array(); 178 178 for ( $i = 0; $i < 5; $i++ ) { 179 $comments_0[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );180 $comments_1[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );179 $comments_0[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); 180 $comments_1[] = self::$factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); 181 181 } 182 182 … … 192 192 */ 193 193 public function test_only_top_level_comments_should_be_included_in_older_count() { 194 $post = $this->factory->post->create();194 $post = self::$factory->post->create(); 195 195 196 196 $now = time(); 197 197 $comment_parents = $comment_children = array(); 198 198 for ( $i = 0; $i < 5; $i++ ) { 199 $parent = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );199 $parent = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) ); 200 200 $comment_parents[ $i ] = $parent; 201 201 202 $child = $this->factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) );202 $child = self::$factory->comment->create( array( 'comment_post_ID' => $post, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 59 ) ), 'comment_parent' => $parent ) ); 203 203 $comment_children[ $i ] = $child; 204 204 } … … 229 229 $now = time(); 230 230 231 $p = $this->factory->post->create();232 $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) );233 $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) );234 $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) );231 $p = self::$factory->post->create(); 232 $c1 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ) ) ); 233 $c2 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 20 ) ) ); 234 $c3 = self::$factory->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); 235 235 236 236 update_option( 'comments_per_page', 2 );
Note: See TracChangeset
for help on using the changeset viewer.