- Timestamp:
- 05/02/2022 10:36:45 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/renderCommentTemplate.php
r53298 r53329 99 99 ); 100 100 101 $this->assertEquals( 102 build_comment_query_vars_from_block( $block ), 101 $this->assertSameSetsWithIndex( 103 102 array( 104 103 'orderby' => 'comment_date_gmt', … … 108 107 'post_id' => self::$custom_post->ID, 109 108 'hierarchical' => 'threaded', 110 ) 109 ), 110 build_comment_query_vars_from_block( $block ) 111 111 ); 112 112 update_option( 'page_comments', true ); … … 195 195 ); 196 196 197 $this->assert Equals(198 '<ol class="wp-block-comment-template"><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread-even depth-1"><div class="has-small-font-size wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content">Hello world</div></li></ol>',199 $block->render()200 ); 201 } 202 203 /** 204 * Test rendering 3nested comments:197 $this->assertSame( 198 str_replace( array( "\n", "\t" ), '', '<ol class="wp-block-comment-template"><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread-even depth-1"><div class="wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content"><p>Hello world</p></div></li></ol>' ), 199 str_replace( array( "\n", "\t" ), '', $block->render() ) 200 ); 201 } 202 203 /** 204 * Test rendering nested comments: 205 205 * 206 206 * └─ comment 1 207 207 * └─ comment 2 208 208 * └─ comment 3 209 * └─ comment 4 210 * └─ comment 5 209 211 * 210 212 * @ticket 55567 … … 213 215 $first_level_ids = self::factory()->comment->create_post_comments( 214 216 self::$custom_post->ID, 215 1,217 2, 216 218 array( 217 219 'comment_parent' => self::$comment_ids[0], … … 246 248 ); 247 249 248 $this->assertEquals( 249 '<ol class="wp-block-comment-template"><li id="comment-' . self::$comment_ids[0] . '" class="comment odd alt thread-odd thread-alt depth-1"><div class="has-small-font-size wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content">Hello world</div><ol><li id="comment-' . $first_level_ids[0] . '" class="comment even depth-2"><div class="has-small-font-size wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content">Hello world</div><ol><li id="comment-' . $second_level_ids[0] . '" class="comment odd alt depth-3"><div class="has-small-font-size wp-block-comment-author-name"><a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" >Test</a></div><div class="wp-block-comment-content">Hello world</div></li></ol></li></ol></li></ol>', 250 $block->render() 250 $top_level_ids = self::$comment_ids; 251 $expected = str_replace( 252 array( "\n", "\t" ), 253 '', 254 <<<END 255 <ol class="wp-block-comment-template"> 256 <li id="comment-{$top_level_ids[0]}" class="comment odd alt thread-odd thread-alt depth-1"> 257 <div class="wp-block-comment-author-name"> 258 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > 259 Test 260 </a> 261 </div> 262 <div class="wp-block-comment-content"> 263 <p>Hello world</p> 264 </div> 265 <ol> 266 <li id="comment-{$first_level_ids[0]}" class="comment even depth-2"> 267 <div class="wp-block-comment-author-name"> 268 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > 269 Test 270 </a> 271 </div> 272 <div class="wp-block-comment-content"> 273 <p>Hello world</p> 274 </div> 275 <ol> 276 <li id="comment-{$second_level_ids[0]}" class="comment odd alt depth-3"> 277 <div class="wp-block-comment-author-name"> 278 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > 279 Test 280 </a> 281 </div> 282 <div class="wp-block-comment-content"> 283 <p>Hello world</p> 284 </div> 285 </li> 286 </ol> 287 </li> 288 <li id="comment-{$first_level_ids[1]}" class="comment even depth-2"> 289 <div class="wp-block-comment-author-name"> 290 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > 291 Test 292 </a> 293 </div> 294 <div class="wp-block-comment-content"> 295 <p>Hello world</p> 296 </div> 297 </li> 298 </ol> 299 </li> 300 </ol> 301 END 302 ); 303 304 $this->assertSame( 305 $expected, 306 str_replace( array( "\n", "\t" ), '', $block->render() ) 251 307 ); 252 308 }
Note: See TracChangeset
for help on using the changeset viewer.