Changeset 42343 for trunk/tests/phpunit/tests/comment/wpListComments.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/wpListComments.php
r37655 r42343 12 12 13 13 $comments = array(); 14 $now = time(); 15 for ( $i = 0; $i <= 5; $i++ ) { 16 $comments[] = self::factory()->comment->create( array( 17 'comment_post_ID' => $p, 18 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 19 'comment_author' => 'Commenter ' . $i, 20 ) ); 21 } 22 23 update_option( 'page_comments', true ); 24 update_option( 'comments_per_page', 2 ); 25 26 $this->go_to( get_permalink( $p ) ); 27 28 // comments_template() populates $wp_query->comments 29 get_echo( 'comments_template' ); 30 31 $found = wp_list_comments( array( 32 'page' => 2, 33 'echo' => false, 34 ) ); 14 $now = time(); 15 for ( $i = 0; $i <= 5; $i++ ) { 16 $comments[] = self::factory()->comment->create( 17 array( 18 'comment_post_ID' => $p, 19 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 20 'comment_author' => 'Commenter ' . $i, 21 ) 22 ); 23 } 24 25 update_option( 'page_comments', true ); 26 update_option( 'comments_per_page', 2 ); 27 28 $this->go_to( get_permalink( $p ) ); 29 30 // comments_template() populates $wp_query->comments 31 get_echo( 'comments_template' ); 32 33 $found = wp_list_comments( 34 array( 35 'page' => 2, 36 'echo' => false, 37 ) 38 ); 35 39 36 40 preg_match_all( '|id="comment\-([0-9]+)"|', $found, $matches ); … … 46 50 47 51 $comments = array(); 48 $now = time(); 49 for ( $i = 0; $i <= 5; $i++ ) { 50 $comments[] = self::factory()->comment->create( array( 51 'comment_post_ID' => $p, 52 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 53 'comment_author' => 'Commenter ' . $i, 54 ) ); 55 } 56 57 update_option( 'page_comments', true ); 58 update_option( 'comments_per_page', 2 ); 59 60 $this->go_to( get_permalink( $p ) ); 61 62 // comments_template() populates $wp_query->comments 63 get_echo( 'comments_template' ); 64 65 $found = wp_list_comments( array( 66 'per_page' => 3, 67 'echo' => false, 68 ) ); 52 $now = time(); 53 for ( $i = 0; $i <= 5; $i++ ) { 54 $comments[] = self::factory()->comment->create( 55 array( 56 'comment_post_ID' => $p, 57 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 58 'comment_author' => 'Commenter ' . $i, 59 ) 60 ); 61 } 62 63 update_option( 'page_comments', true ); 64 update_option( 'comments_per_page', 2 ); 65 66 $this->go_to( get_permalink( $p ) ); 67 68 // comments_template() populates $wp_query->comments 69 get_echo( 'comments_template' ); 70 71 $found = wp_list_comments( 72 array( 73 'per_page' => 3, 74 'echo' => false, 75 ) 76 ); 69 77 70 78 preg_match_all( '|id="comment\-([0-9]+)"|', $found, $matches ); … … 80 88 81 89 $comments = array(); 82 $now = time(); 83 for ( $i = 0; $i <= 5; $i++ ) { 84 $comments[] = self::factory()->comment->create( array( 85 'comment_post_ID' => $p, 86 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 87 'comment_author' => 'Commenter ' . $i, 88 ) ); 89 } 90 91 update_option( 'page_comments', true ); 92 update_option( 'comments_per_page', 2 ); 93 94 $this->go_to( get_permalink( $p ) ); 95 96 // comments_template() populates $wp_query->comments 97 get_echo( 'comments_template' ); 98 99 $found1 = wp_list_comments( array( 100 'reverse_top_level' => true, 101 'echo' => false, 102 ) ); 90 $now = time(); 91 for ( $i = 0; $i <= 5; $i++ ) { 92 $comments[] = self::factory()->comment->create( 93 array( 94 'comment_post_ID' => $p, 95 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 96 'comment_author' => 'Commenter ' . $i, 97 ) 98 ); 99 } 100 101 update_option( 'page_comments', true ); 102 update_option( 'comments_per_page', 2 ); 103 104 $this->go_to( get_permalink( $p ) ); 105 106 // comments_template() populates $wp_query->comments 107 get_echo( 'comments_template' ); 108 109 $found1 = wp_list_comments( 110 array( 111 'reverse_top_level' => true, 112 'echo' => false, 113 ) 114 ); 103 115 preg_match_all( '|id="comment\-([0-9]+)"|', $found1, $matches ); 104 116 $this->assertSame( array( $comments[0], $comments[1] ), array_map( 'intval', $matches[1] ) ); 105 117 106 $found2 = wp_list_comments( array( 107 'reverse_top_level' => false, 108 'echo' => false, 109 ) ); 118 $found2 = wp_list_comments( 119 array( 120 'reverse_top_level' => false, 121 'echo' => false, 122 ) 123 ); 110 124 preg_match_all( '|id="comment\-([0-9]+)"|', $found2, $matches ); 111 125 $this->assertSame( array( $comments[1], $comments[0] ), array_map( 'intval', $matches[1] ) ); … … 120 134 121 135 $comments = array(); 122 $now = time(); 123 for ( $i = 0; $i <= 5; $i++ ) { 124 $comments[] = self::factory()->comment->create( array( 125 'comment_post_ID' => $p, 126 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 127 'comment_author' => 'Commenter ' . $i, 128 ) ); 136 $now = time(); 137 for ( $i = 0; $i <= 5; $i++ ) { 138 $comments[] = self::factory()->comment->create( 139 array( 140 'comment_post_ID' => $p, 141 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 142 'comment_author' => 'Commenter ' . $i, 143 ) 144 ); 129 145 } 130 146 … … 138 154 get_echo( 'comments_template' ); 139 155 140 $found = wp_list_comments( array( 141 'echo' => false, 142 'per_page' => 1, 143 'page' => 2, 144 ), $_comments ); 156 $found = wp_list_comments( 157 array( 158 'echo' => false, 159 'per_page' => 1, 160 'page' => 2, 161 ), $_comments 162 ); 145 163 146 164 preg_match_all( '|id="comment\-([0-9]+)"|', $found, $matches ); … … 155 173 156 174 $comments = array(); 157 $now = time(); 158 for ( $i = 0; $i <= 5; $i++ ) { 159 $comments[] = self::factory()->comment->create( array( 160 'comment_post_ID' => $p, 161 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 162 'comment_author' => 'Commenter ' . $i, 163 ) ); 175 $now = time(); 176 for ( $i = 0; $i <= 5; $i++ ) { 177 $comments[] = self::factory()->comment->create( 178 array( 179 'comment_post_ID' => $p, 180 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 181 'comment_author' => 'Commenter ' . $i, 182 ) 183 ); 164 184 } 165 185 … … 178 198 get_echo( 'comments_template' ); 179 199 180 $found = wp_list_comments( array( 181 'echo' => false, 182 'per_page' => 1, 183 'page' => 2, 184 ) ); 200 $found = wp_list_comments( 201 array( 202 'echo' => false, 203 'per_page' => 1, 204 'page' => 2, 205 ) 206 ); 185 207 186 208 preg_match_all( '|id="comment\-([0-9]+)"|', $found, $matches ); … … 196 218 197 219 $comments = array(); 198 $now = time(); 199 for ( $i = 0; $i <= 5; $i++ ) { 200 $comments[] = self::factory()->comment->create( array( 201 'comment_post_ID' => $p, 202 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 203 'comment_author' => 'Commenter ' . $i, 204 'user_id' => $u, 205 ) ); 220 $now = time(); 221 for ( $i = 0; $i <= 5; $i++ ) { 222 $comments[] = self::factory()->comment->create( 223 array( 224 'comment_post_ID' => $p, 225 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - $i ), 226 'comment_author' => 'Commenter ' . $i, 227 'user_id' => $u, 228 ) 229 ); 206 230 } 207 231 … … 222 246 get_echo( 'comments_template' ); 223 247 224 $found = wp_list_comments( array( 225 'echo' => false, 226 'per_page' => 1, 227 'page' => 2, 228 ) ); 248 $found = wp_list_comments( 249 array( 250 'echo' => false, 251 'per_page' => 1, 252 'page' => 2, 253 ) 254 ); 229 255 230 256 preg_match_all( '|id="comment\-([0-9]+)"|', $found, $matches );
Note: See TracChangeset
for help on using the changeset viewer.