Changeset 53430
- Timestamp:
- 05/23/2022 11:54:28 AM (2 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r53349 r53430 172 172 $current_screen_globals = array( 'current_screen', 'taxnow', 'typenow' ); 173 173 foreach ( $current_screen_globals as $global ) { 174 $GLOBALS[ $global ] = null; 175 } 176 177 // Reset comment globals. 178 $comment_globals = array( 'comment_alt', 'comment_depth', 'comment_thread_alt' ); 179 foreach ( $comment_globals as $global ) { 174 180 $GLOBALS[ $global ] = null; 175 181 } -
trunk/tests/phpunit/tests/blocks/renderCommentTemplate.php
r53388 r53430 21 21 private static $per_page = 5; 22 22 23 /** 24 * Array of the comments options and their original values. 25 * Used to reset the options after each test. 26 * 27 * @var array 28 */ 29 private static $original_options; 30 31 public static function set_up_before_class() { 32 parent::set_up_before_class(); 33 34 // Store the original option values. 35 $options = array( 36 'comment_order', 37 'comments_per_page', 38 'default_comments_page', 39 'page_comments', 40 'previous_default_page', 41 'thread_comments_depth', 42 ); 43 foreach ( $options as $option ) { 44 static::$original_options[ $option ] = get_option( $option ); 45 } 46 } 47 48 public function tear_down() { 49 // Reset the comment options to their original values. 50 foreach ( static::$original_options as $option => $original_value ) { 51 update_option( $option, $original_value ); 52 } 53 54 parent::tear_down(); 55 } 56 23 57 public function set_up() { 24 58 parent::set_up(); … … 26 60 update_option( 'page_comments', true ); 27 61 update_option( 'comments_per_page', self::$per_page ); 28 update_option( 'comment_order', 'ASC' );29 62 30 63 self::$custom_post = self::factory()->post->create_and_get( … … 110 143 build_comment_query_vars_from_block( $block ) 111 144 ); 112 update_option( 'page_comments', true );113 145 } 114 146 … … 188 220 build_comment_query_vars_from_block( $block ) 189 221 ); 190 191 update_option( 'comments_per_page', $comments_per_page );192 update_option( 'default_comments_page', $default_comments_page );193 222 } 194 223 … … 309 338 <<<END 310 339 <ol class="wp-block-comment-template"> 311 <li id="comment-{$top_level_ids[0]}" class="comment odd alt thread-odd thread-altdepth-1">340 <li id="comment-{$top_level_ids[0]}" class="comment even thread-even depth-1"> 312 341 <div class="wp-block-comment-author-name"> 313 342 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > … … 319 348 </div> 320 349 <ol> 321 <li id="comment-{$first_level_ids[0]}" class="comment evendepth-2">350 <li id="comment-{$first_level_ids[0]}" class="comment odd alt depth-2"> 322 351 <div class="wp-block-comment-author-name"> 323 352 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > … … 329 358 </div> 330 359 <ol> 331 <li id="comment-{$second_level_ids[0]}" class="comment odd altdepth-3">360 <li id="comment-{$second_level_ids[0]}" class="comment even depth-3"> 332 361 <div class="wp-block-comment-author-name"> 333 362 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > … … 341 370 </ol> 342 371 </li> 343 <li id="comment-{$first_level_ids[1]}" class="comment evendepth-2">372 <li id="comment-{$first_level_ids[1]}" class="comment odd alt depth-2"> 344 373 <div class="wp-block-comment-author-name"> 345 374 <a rel="external nofollow ugc" href="http://example.com/author-url/" target="_self" > … … 391 420 392 421 $this->assertSame( 393 '<ol class="wp-block-comment-template"><li id="comment-' . self::$comment_ids[0] . '" class="comment odd altthread-even depth-1"><div class="wp-block-comment-content">' . $expected_content . '</div></li></ol>',422 '<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-content">' . $expected_content . '</div></li></ol>', 394 423 $block->render() 395 424 ); … … 476 505 477 506 $this->assertSame( 478 '<ol class="wp-block-comment-template"><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread- odd thread-alt 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><li id="comment-' . $unapproved_comment[0] . '" class="comment odd alt thread-evendepth-1"><div class="wp-block-comment-author-name">Visitor</div><div class="wp-block-comment-content"><p><em class="comment-awaiting-moderation">Your comment is awaiting moderation.</em></p>Hi there! My comment needs moderation.</div></li></ol>',507 '<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><li id="comment-' . $unapproved_comment[0] . '" class="comment odd alt thread-odd thread-alt depth-1"><div class="wp-block-comment-author-name">Visitor</div><div class="wp-block-comment-content"><p><em class="comment-awaiting-moderation">Your comment is awaiting moderation.</em></p>Hi there! My comment needs moderation.</div></li></ol>', 479 508 str_replace( array( "\n", "\t" ), '', $block->render() ), 480 509 'Should include unapproved comments when filter applied' … … 485 514 // Test it again and ensure the unmoderated comment doesn't leak out. 486 515 $this->assertSame( 487 '<ol class="wp-block-comment-template"><li id="comment-' . self::$comment_ids[0] . '" class="comment even thread- odd thread-altdepth-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>',516 '<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>', 488 517 str_replace( array( "\n", "\t" ), '', $block->render() ), 489 518 'Should not include any unapproved comments after removing filter'
Note: See TracChangeset
for help on using the changeset viewer.