mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.4
This commit is contained in:
commit
22a198a8ba
2 changed files with 28 additions and 1 deletions
|
@ -396,7 +396,9 @@ class PaginatorComponent extends Component {
|
|||
}
|
||||
$options['order'] = $order;
|
||||
}
|
||||
|
||||
if (empty($options['order']) && !empty($object->order)) {
|
||||
$options['order'] = $object->order;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
|
|
@ -577,6 +577,31 @@ class PaginatorComponentTest extends CakeTestCase {
|
|||
$this->assertEquals(array(3, 2, 1), $results);
|
||||
}
|
||||
|
||||
/**
|
||||
* test paginate() and model default order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPaginateOrderModelDefault() {
|
||||
$Controller = new PaginatorTestController($this->request);
|
||||
$Controller->uses = array('PaginatorControllerPost');
|
||||
$Controller->params['url'] = array();
|
||||
$Controller->constructClasses();
|
||||
$Controller->PaginatorControllerPost->order = array(
|
||||
$Controller->PaginatorControllerPost->alias . '.created' => 'desc'
|
||||
);
|
||||
|
||||
$Controller->Paginator->settings = array(
|
||||
'fields' => array('id', 'title', 'created'),
|
||||
'maxLimit' => 10,
|
||||
'paramType' => 'named'
|
||||
);
|
||||
$result = $Controller->Paginator->paginate('PaginatorControllerPost');
|
||||
$expected = array('2007-03-18 10:43:23', '2007-03-18 10:41:23', '2007-03-18 10:39:23');
|
||||
$this->assertEquals($expected, Hash::extract($result, '{n}.PaginatorControllerPost.created'));
|
||||
$this->assertEquals($Controller->PaginatorControllerPost->order, $this->Controller->request['paging']['PaginatorControllerPost']['order']);
|
||||
}
|
||||
|
||||
/**
|
||||
* test paginate() and virtualField interactions
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue