Merge branch 'master' into 2.4

This commit is contained in:
mark_story 2013-07-04 21:40:51 -04:00
commit 22a198a8ba
2 changed files with 28 additions and 1 deletions

View file

@ -396,7 +396,9 @@ class PaginatorComponent extends Component {
}
$options['order'] = $order;
}
if (empty($options['order']) && !empty($object->order)) {
$options['order'] = $object->order;
}
return $options;
}

View file

@ -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
*