@@ -52,11 +52,17 @@ public function test_defaults() {
5252 $ this ->assertSameIgnoreEOL ( $ expected , $ links );
5353 }
5454
55- public function test_format () {
56- $ page2 = home_url ( '/page/2/ ' );
57- $ page3 = home_url ( '/page/3/ ' );
58- $ page50 = home_url ( '/page/50/ ' );
59-
55+ /**
56+ * Test the format parameter behaves as expected.
57+ *
58+ * @dataProvider data_format
59+ *
60+ * @param string $format Format to test.
61+ * @param string $page2 Expected URL for page 2.
62+ * @param string $page3 Expected URL for page 3.
63+ * @param string $page50 Expected URL for page 50.
64+ */
65+ public function test_format ( $ format , $ page2 , $ page3 , $ page50 ) {
6066 $ expected = <<<EXPECTED
6167<span aria-current="page" class="page-numbers current">1</span>
6268<a class="page-numbers" href=" $ page2">2</a>
@@ -69,12 +75,27 @@ public function test_format() {
6975 $ links = paginate_links (
7076 array (
7177 'total ' => 50 ,
72- 'format ' => ' page/%#%/ ' ,
78+ 'format ' => $ format ,
7379 )
7480 );
7581 $ this ->assertSameIgnoreEOL ( $ expected , $ links );
7682 }
7783
84+ /**
85+ * Data provider for test_format.
86+ *
87+ * @return array[] Data provider.
88+ */
89+ public function data_format () {
90+ return array (
91+ 'pretty permalinks ' => array ( 'page/%#%/ ' , home_url ( '/page/2/ ' ), home_url ( '/page/3/ ' ), home_url ( '/page/50/ ' ) ),
92+ 'plain permalinks ' => array ( '?page=%#% ' , home_url ( '/?page=2 ' ), home_url ( '/?page=3 ' ), home_url ( '/?page=50 ' ) ),
93+ 'custom format - html extension ' => array ( 'page/%#%.html ' , home_url ( '/page/2.html ' ), home_url ( '/page/3.html ' ), home_url ( '/page/50.html ' ) ),
94+ 'custom format - hyphen separated ' => array ( 'page-%#% ' , home_url ( '/page-2 ' ), home_url ( '/page-3 ' ), home_url ( '/page-50 ' ) ),
95+ 'custom format - fragment ' => array ( '#%#% ' , home_url ( '/#2 ' ), home_url ( '/#3 ' ), home_url ( '/#50 ' ) ),
96+ );
97+ }
98+
7899 public function test_prev_next_false () {
79100 $ home = home_url ( '/ ' );
80101 $ page3 = get_pagenum_link ( 3 );
0 commit comments