Browse Source

Add test case.

mscherer 7 years ago
parent
commit
c2df1fb71a
1 changed files with 37 additions and 0 deletions
  1. 37 0
      tests/TestCase/Datasource/PaginatorTest.php

+ 37 - 0
tests/TestCase/Datasource/PaginatorTest.php

@@ -248,6 +248,43 @@ class PaginatorTest extends TestCase
     }
 
     /**
+     * Tests that flat default pagination parameters work for multi order.
+     *
+     * @return void
+     */
+    public function testDefaultPaginateParamsMultiOrder()
+    {
+        $settings = [
+            'order' => ['PaginatorPosts.id' => 'DESC', 'PaginatorPosts.title' => 'ASC'],
+        ];
+
+        $table = $this->_getMockPosts(['query']);
+        $query = $this->_getMockFindQuery();
+
+        $table->expects($this->once())
+            ->method('query')
+            ->will($this->returnValue($query));
+
+        $query->expects($this->once())
+            ->method('applyOptions')
+            ->with([
+                'limit' => 20,
+                'page' => 1,
+                'order' => $settings['order'],
+                'whitelist' => ['limit', 'sort', 'page', 'direction'],
+                'scope' => null,
+                'sort' => null,
+            ]);
+
+        $this->Paginator->paginate($table, [], $settings);
+
+        $pagingParams = $this->Paginator->getPagingParams();
+        $this->assertNull($pagingParams['PaginatorPosts']['direction']);
+        $this->assertFalse($pagingParams['PaginatorPosts']['sortDefault']);
+        $this->assertFalse($pagingParams['PaginatorPosts']['directionDefault']);
+    }
+
+    /**
      * test that default sort and default direction are injected into request
      *
      * @return void