Make WordPress Core

Changeset 60100


Ignore:
Timestamp:
03/26/2025 11:31:51 PM (9 months ago)
Author:
peterwilsoncc
Message:

Build/Test Tools: Expand tests of paginate_links' format parameter.

Introduces additional tests for custom formatted pagination links to include:

  • plain permalinks
  • html file extensions
  • hyphen separated links
  • URL fragments

See #63167.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/paginateLinks.php

    r60088 r60100  
    3434    }
    3535
    36     public function test_format() {
    37         $page2  = home_url( '/page/2/' );
    38         $page3  = home_url( '/page/3/' );
    39         $page50 = home_url( '/page/50/' );
    40 
     36    /**
     37     * Test the format parameter behaves as expected.
     38     *
     39     * @dataProvider data_format
     40     *
     41     * @param string $format Format to test.
     42     * @param string $page2  Expected URL for page 2.
     43     * @param string $page3  Expected URL for page 3.
     44     * @param string $page50 Expected URL for page 50.
     45     */
     46    public function test_format( $format, $page2, $page3, $page50 ) {
    4147        $expected = <<<EXPECTED
    4248<span aria-current="page" class="page-numbers current">1</span>
     
    5157            array(
    5258                'total'  => 50,
    53                 'format' => 'page/%#%/',
     59                'format' => $format,
    5460            )
    5561        );
    5662        $this->assertSameIgnoreEOL( $expected, $links );
     63    }
     64
     65    /**
     66     * Data provider for test_format.
     67     *
     68     * @return array[] Data provider.
     69     */
     70    public function data_format() {
     71        return array(
     72            'pretty permalinks'                => array( 'page/%#%/', home_url( '/page/2/' ), home_url( '/page/3/' ), home_url( '/page/50/' ) ),
     73            'plain permalinks'                 => array( '?page=%#%', home_url( '/?page=2' ), home_url( '/?page=3' ), home_url( '/?page=50' ) ),
     74            'custom format - html extension'   => array( 'page/%#%.html', home_url( '/page/2.html' ), home_url( '/page/3.html' ), home_url( '/page/50.html' ) ),
     75            'custom format - hyphen separated' => array( 'page-%#%', home_url( '/page-2' ), home_url( '/page-3' ), home_url( '/page-50' ) ),
     76            'custom format - fragment'         => array( '#%#%', home_url( '/#2' ), home_url( '/#3' ), home_url( '/#50' ) ),
     77        );
    5778    }
    5879
Note: See TracChangeset for help on using the changeset viewer.