Make WordPress Core


Ignore:
Timestamp:
03/24/2023 02:58:39 PM (19 months ago)
Author:
SergeyBiryukov
Message:

Tests: Move the wp_list_pages() test for CSS classes to a more appropriate place.

Back when this test was introduced, wp_list_pages() did not have its own test class.

It does now, so the test can be moved there, instead of being hidden among get_pages() tests.

Includes:

  • Updating the test name for clarity.
  • Adding an unique message for each assertion.

Follow-up to [27755], [28400].

See #57841.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getPages.php

    r55583 r55588  
    741741    }
    742742
    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 
    776743    /**
    777744     * @ticket 12821
Note: See TracChangeset for help on using the changeset viewer.