Changeset 53258
- Timestamp:
- 04/25/2022 04:10:54 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/renderCommentTemplate.php
r53214 r53258 45 45 'comment_author' => 'Test', 46 46 'comment_author_email' => 'test@example.org', 47 'comment_author_url' => 'http://example.com/author-url/', 47 48 'comment_content' => 'Hello world', 48 49 ) … … 82 83 83 84 /** 85 * @ticket 55567 86 * @covers ::build_comment_query_vars_from_block 87 */ 88 function test_build_comment_query_vars_from_block_with_context_no_pagination() { 89 update_option( 'page_comments', false ); 90 $parsed_blocks = parse_blocks( 91 '<!-- wp:comment-template --><!-- wp:comment-author-name /--><!-- wp:comment-content /--><!-- /wp:comment-template -->' 92 ); 93 94 $block = new WP_Block( 95 $parsed_blocks[0], 96 array( 97 'postId' => self::$custom_post->ID, 98 ) 99 ); 100 101 $this->assertEquals( 102 build_comment_query_vars_from_block( $block ), 103 array( 104 'orderby' => 'comment_date_gmt', 105 'order' => 'ASC', 106 'status' => 'approve', 107 'no_found_rows' => false, 108 'post_id' => self::$custom_post->ID, 109 'hierarchical' => 'threaded', 110 ) 111 ); 112 update_option( 'page_comments', true ); 113 } 114 115 /** 84 116 * @ticket 55505 85 117 * @covers ::build_comment_query_vars_from_block … … 126 158 'comment_author' => 'Test', 127 159 'comment_author_email' => 'test@example.org', 160 'comment_author_url' => 'http://example.com/author-url/', 128 161 'comment_content' => 'Hello world', 129 162 ) … … 144 177 $this->assertSame( $comment_query_max_num_pages, get_query_var( 'cpage' ) ); 145 178 } 179 180 /** 181 * Test rendering a single comment 182 * 183 * @ticket 55567 184 */ 185 function test_rendering_comment_template() { 186 $parsed_blocks = parse_blocks( 187 '<!-- wp:comment-template --><!-- wp:comment-author-name /--><!-- wp:comment-content /--><!-- /wp:comment-template -->' 188 ); 189 190 $block = new WP_Block( 191 $parsed_blocks[0], 192 array( 193 'postId' => self::$custom_post->ID, 194 ) 195 ); 196 197 $this->assertEquals( 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 3 nested comments: 205 * 206 * └─ comment 1 207 * └─ comment 2 208 * └─ comment 3 209 * 210 * @ticket 55567 211 */ 212 function test_rendering_comment_template_nested() { 213 $first_level_ids = self::factory()->comment->create_post_comments( 214 self::$custom_post->ID, 215 1, 216 array( 217 'comment_parent' => self::$comment_ids[0], 218 'comment_author' => 'Test', 219 'comment_author_email' => 'test@example.org', 220 'comment_author_url' => 'http://example.com/author-url/', 221 'comment_content' => 'Hello world', 222 ) 223 ); 224 225 $second_level_ids = self::factory()->comment->create_post_comments( 226 self::$custom_post->ID, 227 1, 228 array( 229 'comment_parent' => $first_level_ids[0], 230 'comment_author' => 'Test', 231 'comment_author_email' => 'test@example.org', 232 'comment_author_url' => 'http://example.com/author-url/', 233 'comment_content' => 'Hello world', 234 ) 235 ); 236 237 $parsed_blocks = parse_blocks( 238 '<!-- wp:comment-template --><!-- wp:comment-author-name /--><!-- wp:comment-content /--><!-- /wp:comment-template -->' 239 ); 240 241 $block = new WP_Block( 242 $parsed_blocks[0], 243 array( 244 'postId' => self::$custom_post->ID, 245 ) 246 ); 247 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() 251 ); 252 } 146 253 }
Note: See TracChangeset
for help on using the changeset viewer.