- Timestamp:
- 03/24/2023 02:58:39 PM (19 months ago)
- Location:
- trunk/tests/phpunit/tests/post
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPages.php
r55583 r55588 741 741 } 742 742 743 public function test_wp_list_pages_classes() {744 $type = 'taco';745 register_post_type(746 $type,747 array(748 'hierarchical' => true,749 'public' => true,750 )751 );752 753 $posts = self::factory()->post->create_many( 2, array( 'post_type' => $type ) );754 $post_id = reset( $posts );755 756 $this->go_to( "/?p=$post_id&post_type=$type" );757 758 $this->assertSame( $post_id, get_queried_object_id() );759 760 $output = wp_list_pages(761 array(762 'echo' => false,763 'title_li' => '',764 'post_type' => $type,765 )766 );767 768 $this->assertNotEmpty( $output );769 $this->assertSame( 2, substr_count( $output, 'class="page_item ' ) );770 $this->assertStringContainsString( 'current_page_item', $output );771 $this->assertSame( 1, substr_count( $output, 'current_page_item' ) );772 773 _unregister_post_type( $type );774 }775 776 743 /** 777 744 * @ticket 12821 -
trunk/tests/phpunit/tests/post/wpListPages.php
r52010 r55588 449 449 $this->assertSame( $expected, wp_list_pages( $args ) ); 450 450 } 451 452 public function test_wp_list_pages_classes_with_hierarchical_cpt() { 453 $args = array( 454 'echo' => false, 455 'post_type' => 'taco', 456 ); 457 458 register_post_type( 459 $args['post_type'], 460 array( 461 'hierarchical' => true, 462 'public' => true, 463 ) 464 ); 465 466 $posts = self::factory()->post->create_many( 2, array( 'post_type' => $args['post_type'] ) ); 467 $post_id = reset( $posts ); 468 469 $this->go_to( "/?p={$post_id}&post_type={$args['post_type']}" ); 470 471 $this->assertSame( 472 $post_id, 473 get_queried_object_id(), 474 'The queried object ID should match the ID of the requested CPT item.' 475 ); 476 477 $output = wp_list_pages( $args ); 478 479 _unregister_post_type( $args['post_type'] ); 480 481 $this->assertNotEmpty( 482 $output, 483 'The output should not be empty.' 484 ); 485 486 $this->assertSame( 487 2, 488 substr_count( $output, 'class="page_item ' ), 489 'The number of "page_item" classes should be equal to the total CPT items count.' 490 ); 491 492 $this->assertStringContainsString( 493 'current_page_item', 494 $output, 495 'The output should contain the "current_page_item" class.' 496 ); 497 498 $this->assertSame( 499 1, 500 substr_count( $output, 'current_page_item' ), 501 'The output should contain exactly one "current_page_item" class.' 502 ); 503 } 451 504 }
Note: See TracChangeset
for help on using the changeset viewer.