@@ -33,11 +33,17 @@ public function test_defaults() {
3333 $ this ->assertSameIgnoreEOL ( $ expected , $ links );
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>
4349<a class="page-numbers" href=" $ page2">2</a>
@@ -50,12 +56,27 @@ public function test_format() {
5056 $ links = paginate_links (
5157 array (
5258 'total ' => 50 ,
53- 'format ' => ' page/%#%/ ' ,
59+ 'format ' => $ format ,
5460 )
5561 );
5662 $ this ->assertSameIgnoreEOL ( $ expected , $ links );
5763 }
5864
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+ );
78+ }
79+
5980 public function test_prev_next_false () {
6081 $ home = home_url ( '/ ' );
6182 $ page3 = get_pagenum_link ( 3 );
0 commit comments