Browse Source

Add test for changing direction on multiple results

Test that sort links on non-default models switch directions correctly.

Refs #10442
Mark Story 9 years ago
parent
commit
82ee9a8231
1 changed files with 20 additions and 1 deletions
  1. 20 1
      tests/TestCase/View/Helper/PaginatorHelperTest.php

+ 20 - 1
tests/TestCase/View/Helper/PaginatorHelperTest.php

@@ -457,16 +457,35 @@ class PaginatorHelperTest extends TestCase
                 'direction' => 'asc',
                 'page' => 1,
                 'scope' => 'article',
+            ],
+            'Tags' => [
+                'current' => 1,
+                'count' => 100,
+                'prevPage' => false,
+                'nextPage' => true,
+                'pageCount' => 5,
+                'sort' => 'tag',
+                'direction' => 'asc',
+                'page' => 1,
+                'scope' => 'tags',
             ]
         ];
 
-        $result = $this->Paginator->sort('title');
+        $result = $this->Paginator->sort('title', 'Title', ['model' => 'Articles']);
         $expected = [
             'a' => ['href' => '/accounts/index?article%5Bsort%5D=title&article%5Bdirection%5D=asc'],
             'Title',
             '/a'
         ];
         $this->assertHtml($expected, $result);
+
+        $result = $this->Paginator->sort('tag', 'Tag', ['model' => 'Tags']);
+        $expected = [
+            'a' => ['class' => 'asc', 'href' => '/accounts/index?tags%5Bsort%5D=tag&tags%5Bdirection%5D=desc'],
+            'Tag',
+            '/a'
+        ];
+        $this->assertHtml($expected, $result);
     }
 
     /**