mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Working on virtual fields on order clause.
This commit is contained in:
parent
0ab2078284
commit
2503632327
2 changed files with 19 additions and 1 deletions
|
@ -1018,7 +1018,7 @@ class Model extends Overloadable {
|
||||||
function hasField($name, $checkVirtual = false) {
|
function hasField($name, $checkVirtual = false) {
|
||||||
if (is_array($name)) {
|
if (is_array($name)) {
|
||||||
foreach ($name as $n) {
|
foreach ($name as $n) {
|
||||||
if ($this->hasField($n)) {
|
if ($this->hasField($n,$checkVirtual)) {
|
||||||
return $n;
|
return $n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -688,6 +688,24 @@ class ControllerTest extends CakeTestCase {
|
||||||
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0]));
|
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testPaginateOrderVirtualField() {
|
||||||
|
$Controller =& new Controller();
|
||||||
|
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
||||||
|
$Controller->passedArgs[] = '1';
|
||||||
|
$Controller->params['url'] = array();
|
||||||
|
$Controller->constructClasses();
|
||||||
|
$Controller->ControllerPost->virtualFields = array('offset_test' => 'ControllerPost.id + 1');
|
||||||
|
|
||||||
|
$Controller->paginate = array(
|
||||||
|
'fields' => array('id', 'title'),
|
||||||
|
'order' => 'offset_test',
|
||||||
|
'limit' => 1
|
||||||
|
);
|
||||||
|
$result = $Controller->paginate('ControllerPost');
|
||||||
|
|
||||||
|
$this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDefaultPaginateParams method
|
* testDefaultPaginateParams method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue