|
|
@@ -93,7 +93,7 @@ trait PaginatorTestTrait
|
|
|
'contain' => ['PaginatorAuthor'],
|
|
|
'maxLimit' => 10,
|
|
|
'group' => 'PaginatorPosts.published',
|
|
|
- 'order' => ['PaginatorPosts.id' => 'ASC']
|
|
|
+ 'order' => ['PaginatorPosts.id' => 'ASC'],
|
|
|
],
|
|
|
];
|
|
|
$table = $this->_getMockPosts(['query']);
|
|
|
@@ -128,16 +128,16 @@ trait PaginatorTestTrait
|
|
|
$this->loadFixtures('Posts');
|
|
|
$settings = [
|
|
|
'PaginatorPosts' => [
|
|
|
- 'finder' => ['author' => ['author_id' => 1]]
|
|
|
- ]
|
|
|
+ 'finder' => ['author' => ['author_id' => 1]],
|
|
|
+ ],
|
|
|
];
|
|
|
$table = $this->getTableLocator()->get('PaginatorPosts');
|
|
|
|
|
|
$expected = $table
|
|
|
->find('author', [
|
|
|
'conditions' => [
|
|
|
- 'PaginatorPosts.author_id' => 1
|
|
|
- ]
|
|
|
+ 'PaginatorPosts.author_id' => 1,
|
|
|
+ ],
|
|
|
])
|
|
|
->count();
|
|
|
$result = $this->Paginator->paginate($table, [], $settings)->count();
|
|
|
@@ -318,7 +318,7 @@ trait PaginatorTestTrait
|
|
|
'scope' => [
|
|
|
'page' => 2,
|
|
|
'limit' => 5,
|
|
|
- ]
|
|
|
+ ],
|
|
|
];
|
|
|
|
|
|
$settings = [
|
|
|
@@ -386,13 +386,13 @@ trait PaginatorTestTrait
|
|
|
{
|
|
|
$params = [
|
|
|
'page' => 10,
|
|
|
- 'limit' => 10
|
|
|
+ 'limit' => 10,
|
|
|
];
|
|
|
$settings = [
|
|
|
'page' => 1,
|
|
|
'limit' => 20,
|
|
|
'maxLimit' => 100,
|
|
|
- 'finder' => 'myCustomFind'
|
|
|
+ 'finder' => 'myCustomFind',
|
|
|
];
|
|
|
$defaults = $this->Paginator->getDefaults('Post', $settings);
|
|
|
$result = $this->Paginator->mergeOptions($params, $defaults);
|
|
|
@@ -415,7 +415,7 @@ trait PaginatorTestTrait
|
|
|
{
|
|
|
$params = [
|
|
|
'page' => 99,
|
|
|
- 'limit' => 75
|
|
|
+ 'limit' => 75,
|
|
|
];
|
|
|
$settings = [
|
|
|
'page' => 1,
|
|
|
@@ -441,7 +441,7 @@ trait PaginatorTestTrait
|
|
|
'fields' => ['bad.stuff'],
|
|
|
'recursive' => 1000,
|
|
|
'conditions' => ['bad.stuff'],
|
|
|
- 'contain' => ['bad']
|
|
|
+ 'contain' => ['bad'],
|
|
|
];
|
|
|
$settings = [
|
|
|
'page' => 1,
|
|
|
@@ -467,7 +467,7 @@ trait PaginatorTestTrait
|
|
|
'fields' => ['bad.stuff'],
|
|
|
'recursive' => 1000,
|
|
|
'conditions' => ['bad.stuff'],
|
|
|
- 'contain' => ['bad']
|
|
|
+ 'contain' => ['bad'],
|
|
|
];
|
|
|
$settings = [
|
|
|
'page' => 1,
|
|
|
@@ -478,7 +478,7 @@ trait PaginatorTestTrait
|
|
|
$defaults = $this->Paginator->getDefaults('Post', $settings);
|
|
|
$result = $this->Paginator->mergeOptions($params, $defaults);
|
|
|
$expected = [
|
|
|
- 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'fields' => ['bad.stuff'], 'whitelist' => ['limit', 'sort', 'page', 'direction', 'fields']
|
|
|
+ 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'fields' => ['bad.stuff'], 'whitelist' => ['limit', 'sort', 'page', 'direction', 'fields'],
|
|
|
];
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
|
@@ -501,7 +501,7 @@ trait PaginatorTestTrait
|
|
|
'limit' => 100,
|
|
|
'maxLimit' => 100,
|
|
|
'paramType' => 'named',
|
|
|
- 'whitelist' => ['limit', 'sort', 'page', 'direction']
|
|
|
+ 'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
];
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
@@ -516,7 +516,7 @@ trait PaginatorTestTrait
|
|
|
'limit' => 10,
|
|
|
'maxLimit' => 10,
|
|
|
'paramType' => 'named',
|
|
|
- 'whitelist' => ['limit', 'sort', 'page', 'direction']
|
|
|
+ 'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
];
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
|
@@ -533,7 +533,7 @@ trait PaginatorTestTrait
|
|
|
'limit' => 2,
|
|
|
'maxLimit' => 10,
|
|
|
'order' => [
|
|
|
- 'Users.username' => 'asc'
|
|
|
+ 'Users.username' => 'asc',
|
|
|
],
|
|
|
];
|
|
|
$defaults = $this->Paginator->getDefaults('Post', $settings);
|
|
|
@@ -543,9 +543,9 @@ trait PaginatorTestTrait
|
|
|
'limit' => 2,
|
|
|
'maxLimit' => 10,
|
|
|
'order' => [
|
|
|
- 'Users.username' => 'asc'
|
|
|
+ 'Users.username' => 'asc',
|
|
|
],
|
|
|
- 'whitelist' => ['limit', 'sort', 'page', 'direction']
|
|
|
+ 'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
];
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
@@ -554,7 +554,7 @@ trait PaginatorTestTrait
|
|
|
'limit' => 100,
|
|
|
'maxLimit' => 10,
|
|
|
'order' => [
|
|
|
- 'Users.username' => 'asc'
|
|
|
+ 'Users.username' => 'asc',
|
|
|
],
|
|
|
];
|
|
|
$defaults = $this->Paginator->getDefaults('Post', $settings);
|
|
|
@@ -564,9 +564,9 @@ trait PaginatorTestTrait
|
|
|
'limit' => 10,
|
|
|
'maxLimit' => 10,
|
|
|
'order' => [
|
|
|
- 'Users.username' => 'asc'
|
|
|
+ 'Users.username' => 'asc',
|
|
|
],
|
|
|
- 'whitelist' => ['limit', 'sort', 'page', 'direction']
|
|
|
+ 'whitelist' => ['limit', 'sort', 'page', 'direction'],
|
|
|
];
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
|
@@ -598,7 +598,7 @@ trait PaginatorTestTrait
|
|
|
$params = [
|
|
|
'page' => 1,
|
|
|
'sort' => 'id',
|
|
|
- 'direction' => 'herp'
|
|
|
+ 'direction' => 'herp',
|
|
|
];
|
|
|
$this->Paginator->paginate($table, $params);
|
|
|
$pagingParams = $this->Paginator->getPagingParams();
|
|
|
@@ -699,7 +699,7 @@ trait PaginatorTestTrait
|
|
|
$queryParams = [
|
|
|
'page' => 1,
|
|
|
'sort' => 'title',
|
|
|
- 'direction' => 'asc'
|
|
|
+ 'direction' => 'asc',
|
|
|
];
|
|
|
|
|
|
$this->Paginator->paginate($table, $queryParams, $options);
|
|
|
@@ -741,10 +741,10 @@ trait PaginatorTestTrait
|
|
|
$params = [
|
|
|
'page' => 1,
|
|
|
'sort' => 'id',
|
|
|
- 'direction' => 'herp'
|
|
|
+ 'direction' => 'herp',
|
|
|
];
|
|
|
$options = [
|
|
|
- 'sortWhitelist' => ['id']
|
|
|
+ 'sortWhitelist' => ['id'],
|
|
|
];
|
|
|
$this->Paginator->paginate($table, $params, $options);
|
|
|
$pagingParams = $this->Paginator->getPagingParams();
|
|
|
@@ -774,7 +774,7 @@ trait PaginatorTestTrait
|
|
|
$this->assertSame(
|
|
|
[
|
|
|
'requestedPage' => 3000,
|
|
|
- 'pagingParams' => $this->Paginator->getPagingParams()
|
|
|
+ 'pagingParams' => $this->Paginator->getPagingParams(),
|
|
|
],
|
|
|
$exception->getAttributes()
|
|
|
);
|
|
|
@@ -810,7 +810,7 @@ trait PaginatorTestTrait
|
|
|
$options = [
|
|
|
'sort' => 'body',
|
|
|
'direction' => 'asc',
|
|
|
- 'sortWhitelist' => ['title', 'id']
|
|
|
+ 'sortWhitelist' => ['title', 'id'],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
@@ -829,7 +829,7 @@ trait PaginatorTestTrait
|
|
|
$options = [
|
|
|
'sort' => 'body',
|
|
|
'direction' => 'asc',
|
|
|
- 'sortWhitelist' => ['body']
|
|
|
+ 'sortWhitelist' => ['body'],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
@@ -853,11 +853,11 @@ trait PaginatorTestTrait
|
|
|
$options = [
|
|
|
'order' => [
|
|
|
'body' => 'asc',
|
|
|
- 'foo.bar' => 'asc'
|
|
|
+ 'foo.bar' => 'asc',
|
|
|
],
|
|
|
'sort' => 'body',
|
|
|
'direction' => 'asc',
|
|
|
- 'sortWhitelist' => []
|
|
|
+ 'sortWhitelist' => [],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
@@ -881,7 +881,7 @@ trait PaginatorTestTrait
|
|
|
$options = [
|
|
|
'sort' => 'score',
|
|
|
'direction' => 'asc',
|
|
|
- 'sortWhitelist' => ['score']
|
|
|
+ 'sortWhitelist' => ['score'],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
@@ -905,15 +905,15 @@ trait PaginatorTestTrait
|
|
|
$options = [
|
|
|
'order' => [
|
|
|
'body' => 'asc',
|
|
|
- 'foo.bar' => 'asc'
|
|
|
+ 'foo.bar' => 'asc',
|
|
|
],
|
|
|
- 'sortWhitelist' => ['body', 'foo.bar']
|
|
|
+ 'sortWhitelist' => ['body', 'foo.bar'],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
$expected = [
|
|
|
'model.body' => 'asc',
|
|
|
- 'foo.bar' => 'asc'
|
|
|
+ 'foo.bar' => 'asc',
|
|
|
];
|
|
|
$this->assertEquals($expected, $result['order']);
|
|
|
}
|
|
|
@@ -926,7 +926,7 @@ trait PaginatorTestTrait
|
|
|
$model = $this->getMockBuilder('Cake\Datasource\RepositoryInterface')
|
|
|
->setMethods([
|
|
|
'getAlias', 'hasField', 'alias', 'find', 'get', 'query', 'updateAll', 'deleteAll',
|
|
|
- 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities'
|
|
|
+ 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities',
|
|
|
])
|
|
|
->getMock();
|
|
|
|
|
|
@@ -962,13 +962,13 @@ trait PaginatorTestTrait
|
|
|
$options = [
|
|
|
'order' => [
|
|
|
'author_id' => 'asc',
|
|
|
- 'title' => 'asc'
|
|
|
- ]
|
|
|
+ 'title' => 'asc',
|
|
|
+ ],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
$expected = [
|
|
|
'model.author_id' => 'asc',
|
|
|
- 'model.title' => 'asc'
|
|
|
+ 'model.title' => 'asc',
|
|
|
];
|
|
|
|
|
|
$this->assertEquals($expected, $result['order']);
|
|
|
@@ -988,15 +988,15 @@ trait PaginatorTestTrait
|
|
|
'direction' => 'desc',
|
|
|
'order' => [
|
|
|
'author_id' => 'asc',
|
|
|
- 'title' => 'asc'
|
|
|
- ]
|
|
|
+ 'title' => 'asc',
|
|
|
+ ],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
$expected = [
|
|
|
'model.created' => 'desc',
|
|
|
'model.author_id' => 'asc',
|
|
|
- 'model.title' => 'asc'
|
|
|
+ 'model.title' => 'asc',
|
|
|
];
|
|
|
$this->assertEquals($expected, $result['order']);
|
|
|
|
|
|
@@ -1005,8 +1005,8 @@ trait PaginatorTestTrait
|
|
|
'direction' => 'desc',
|
|
|
'order' => [
|
|
|
'author_id' => 'asc',
|
|
|
- 'title' => 'asc'
|
|
|
- ]
|
|
|
+ 'title' => 'asc',
|
|
|
+ ],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
@@ -1030,8 +1030,8 @@ trait PaginatorTestTrait
|
|
|
'sort' => 'created',
|
|
|
'direction' => 'desc',
|
|
|
'order' => [
|
|
|
- 'model.created' => 'asc'
|
|
|
- ]
|
|
|
+ 'model.created' => 'asc',
|
|
|
+ ],
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
|
|
|
@@ -1054,7 +1054,7 @@ trait PaginatorTestTrait
|
|
|
$model = $this->mockAliasHasFieldModel();
|
|
|
|
|
|
$options = [
|
|
|
- 'order' => 'model.author_id DESC'
|
|
|
+ 'order' => 'model.author_id DESC',
|
|
|
];
|
|
|
$result = $this->Paginator->validateSort($model, $options);
|
|
|
$expected = 'model.author_id DESC';
|
|
|
@@ -1164,7 +1164,7 @@ trait PaginatorTestTrait
|
|
|
'maxLimit' => 100,
|
|
|
];
|
|
|
$params = [
|
|
|
- 'limit' => '1000'
|
|
|
+ 'limit' => '1000',
|
|
|
];
|
|
|
$this->Paginator->paginate($table, $params, $settings);
|
|
|
$pagingParams = $this->Paginator->getPagingParams();
|
|
|
@@ -1172,7 +1172,7 @@ trait PaginatorTestTrait
|
|
|
$this->assertEquals(100, $pagingParams['PaginatorPosts']['perPage']);
|
|
|
|
|
|
$params = [
|
|
|
- 'limit' => '10'
|
|
|
+ 'limit' => '10',
|
|
|
];
|
|
|
$this->Paginator->paginate($table, $params, $settings);
|
|
|
$pagingParams = $this->Paginator->getPagingParams();
|
|
|
@@ -1190,7 +1190,7 @@ trait PaginatorTestTrait
|
|
|
{
|
|
|
$settings = [
|
|
|
'finder' => 'published',
|
|
|
- 'limit' => 2
|
|
|
+ 'limit' => 2,
|
|
|
];
|
|
|
$table = $this->_getMockPosts(['query']);
|
|
|
$query = $this->_getMockFindQuery();
|
|
|
@@ -1225,8 +1225,8 @@ trait PaginatorTestTrait
|
|
|
'contain' => ['PaginatorAuthor'],
|
|
|
'maxLimit' => 10,
|
|
|
'group' => 'PaginatorPosts.published',
|
|
|
- 'order' => ['PaginatorPosts.id' => 'ASC']
|
|
|
- ]
|
|
|
+ 'order' => ['PaginatorPosts.id' => 'ASC'],
|
|
|
+ ],
|
|
|
];
|
|
|
$table = $this->_getMockPosts(['find']);
|
|
|
$query = $this->_getMockFindQuery($table);
|
|
|
@@ -1285,8 +1285,8 @@ trait PaginatorTestTrait
|
|
|
'maxLimit' => 10,
|
|
|
'limit' => 5,
|
|
|
'group' => 'PaginatorPosts.published',
|
|
|
- 'order' => ['PaginatorPosts.id' => 'ASC']
|
|
|
- ]
|
|
|
+ 'order' => ['PaginatorPosts.id' => 'ASC'],
|
|
|
+ ],
|
|
|
];
|
|
|
$table = $this->_getMockPosts(['find']);
|
|
|
$query = $this->_getMockFindQuery($table);
|
|
|
@@ -1326,8 +1326,8 @@ trait PaginatorTestTrait
|
|
|
'title' => ['type' => 'string', 'null' => false],
|
|
|
'body' => 'text',
|
|
|
'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'],
|
|
|
- '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]
|
|
|
- ]
|
|
|
+ '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
|
|
|
+ ],
|
|
|
]])
|
|
|
->getMock();
|
|
|
}
|