|
|
@@ -126,6 +126,7 @@ class PaginatorTest extends TestCase
|
|
|
'page' => 1,
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => null,
|
|
|
]);
|
|
|
$this->Paginator->paginate($table, $params, $settings);
|
|
|
}
|
|
|
@@ -237,6 +238,7 @@ class PaginatorTest extends TestCase
|
|
|
'order' => ['PaginatorPosts.id' => 'DESC'],
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => null,
|
|
|
]);
|
|
|
|
|
|
$this->Paginator->paginate($table, [], $settings);
|
|
|
@@ -269,6 +271,7 @@ class PaginatorTest extends TestCase
|
|
|
'order' => ['PaginatorPosts.id' => 'DESC'],
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => null,
|
|
|
]);
|
|
|
|
|
|
$this->Paginator->paginate($table, [], $settings);
|
|
|
@@ -592,6 +595,7 @@ class PaginatorTest extends TestCase
|
|
|
'order' => ['PaginatorPosts.id' => 'asc'],
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => 'id',
|
|
|
]);
|
|
|
|
|
|
$params = [
|
|
|
@@ -601,7 +605,7 @@ class PaginatorTest extends TestCase
|
|
|
];
|
|
|
$this->Paginator->paginate($table, $params);
|
|
|
$pagingParams = $this->Paginator->getPagingParams();
|
|
|
- $this->assertEquals('PaginatorPosts.id', $pagingParams['PaginatorPosts']['sort']);
|
|
|
+ $this->assertEquals('id', $pagingParams['PaginatorPosts']['sort']);
|
|
|
$this->assertEquals('asc', $pagingParams['PaginatorPosts']['direction']);
|
|
|
}
|
|
|
|
|
|
@@ -627,6 +631,45 @@ class PaginatorTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testValidateSortRetainsOriginalSortValue
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ * @see https://github.com/cakephp/cakephp/issues/11740
|
|
|
+ */
|
|
|
+ public function testValidateSortRetainsOriginalSortValue()
|
|
|
+ {
|
|
|
+ $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' => ['PaginatorPosts.id' => 'asc'],
|
|
|
+ 'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
+ 'scope' => null,
|
|
|
+ 'sortWhitelist' => ['id'],
|
|
|
+ 'sort' => 'id',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $params = [
|
|
|
+ 'page' => 1,
|
|
|
+ 'sort' => 'id',
|
|
|
+ 'direction' => 'herp'
|
|
|
+ ];
|
|
|
+ $options = [
|
|
|
+ 'sortWhitelist' => ['id']
|
|
|
+ ];
|
|
|
+ $this->Paginator->paginate($table, $params, $options);
|
|
|
+ $pagingParams = $this->Paginator->getPagingParams();
|
|
|
+ $this->assertEquals('id', $pagingParams['PaginatorPosts']['sort']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Test that a really large page number gets clamped to the max page size.
|
|
|
*
|
|
|
* @return void
|
|
|
@@ -1145,6 +1188,7 @@ class PaginatorTest extends TestCase
|
|
|
'order' => [],
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => null,
|
|
|
]);
|
|
|
$this->Paginator->paginate($table, [], $settings);
|
|
|
}
|
|
|
@@ -1179,6 +1223,7 @@ class PaginatorTest extends TestCase
|
|
|
'page' => 1,
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => null,
|
|
|
]);
|
|
|
$this->Paginator->paginate($query, $params, $settings);
|
|
|
}
|
|
|
@@ -1239,6 +1284,7 @@ class PaginatorTest extends TestCase
|
|
|
'page' => 1,
|
|
|
'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
'scope' => null,
|
|
|
+ 'sort' => null,
|
|
|
]);
|
|
|
$this->Paginator->paginate($query, $params, $settings);
|
|
|
}
|