diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index 516afa25b9..d9833c6245 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -33,11 +33,17 @@ EXPECTED; $this->assertSameIgnoreEOL( $expected, $links ); } - public function test_format() { - $page2 = home_url( '/page/2/' ); - $page3 = home_url( '/page/3/' ); - $page50 = home_url( '/page/50/' ); - + /** + * Test the format parameter behaves as expected. + * + * @dataProvider data_format + * + * @param string $format Format to test. + * @param string $page2 Expected URL for page 2. + * @param string $page3 Expected URL for page 3. + * @param string $page50 Expected URL for page 50. + */ + public function test_format( $format, $page2, $page3, $page50 ) { $expected = <<<EXPECTED <span aria-current="page" class="page-numbers current">1</span> <a class="page-numbers" href="$page2">2</a> @@ -50,12 +56,27 @@ EXPECTED; $links = paginate_links( array( 'total' => 50, - 'format' => 'page/%#%/', + 'format' => $format, ) ); $this->assertSameIgnoreEOL( $expected, $links ); } + /** + * Data provider for test_format. + * + * @return array[] Data provider. + */ + public function data_format() { + return array( + 'pretty permalinks' => array( 'page/%#%/', home_url( '/page/2/' ), home_url( '/page/3/' ), home_url( '/page/50/' ) ), + 'plain permalinks' => array( '?page=%#%', home_url( '/?page=2' ), home_url( '/?page=3' ), home_url( '/?page=50' ) ), + 'custom format - html extension' => array( 'page/%#%.html', home_url( '/page/2.html' ), home_url( '/page/3.html' ), home_url( '/page/50.html' ) ), + 'custom format - hyphen separated' => array( 'page-%#%', home_url( '/page-2' ), home_url( '/page-3' ), home_url( '/page-50' ) ), + 'custom format - fragment' => array( '#%#%', home_url( '/#2' ), home_url( '/#3' ), home_url( '/#50' ) ), + ); + } + public function test_prev_next_false() { $home = home_url( '/' ); $page3 = get_pagenum_link( 3 );