mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
- Tests for array order syntax fix
This commit is contained in:
parent
b539161b2d
commit
ee1980b8f5
1 changed files with 21 additions and 0 deletions
|
@ -320,12 +320,20 @@ class PaginatorComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
$Controller->PaginatorControllerPost->order = null;
|
$Controller->PaginatorControllerPost->order = null;
|
||||||
|
|
||||||
|
/* ORDER ARRAY FIELD => SORT MODE */
|
||||||
$Controller->Paginator->settings = array(
|
$Controller->Paginator->settings = array(
|
||||||
'order' => array('PaginatorControllerComment.id' => 'ASC')
|
'order' => array('PaginatorControllerComment.id' => 'ASC')
|
||||||
);
|
);
|
||||||
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id');
|
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id');
|
||||||
$this->assertEquals(array(1, 2, 3, 4, 5, 6), $results);
|
$this->assertEquals(array(1, 2, 3, 4, 5, 6), $results);
|
||||||
|
|
||||||
|
/* ORDER ARRAY "FIELD SORT" MODE */
|
||||||
|
$Controller->Paginator->settings = array(
|
||||||
|
'order' => array('PaginatorControllerComment.id DESC')
|
||||||
|
);
|
||||||
|
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id');
|
||||||
|
$this->assertEquals(array(6, 5, 4, 3, 2, 1), $results);
|
||||||
|
|
||||||
$Controller->Paginator->settings = array(
|
$Controller->Paginator->settings = array(
|
||||||
'order' => array('PaginatorControllerPost.id' => 'ASC')
|
'order' => array('PaginatorControllerPost.id' => 'ASC')
|
||||||
);
|
);
|
||||||
|
@ -619,6 +627,7 @@ class PaginatorComponentTest extends CakeTestCase {
|
||||||
$result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array());
|
$result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array());
|
||||||
$this->assertArrayNotHasKey('order', $result);
|
$this->assertArrayNotHasKey('order', $result);
|
||||||
|
|
||||||
|
/* DEFAULT */
|
||||||
$Controller->PaginatorControllerPost->order = array(
|
$Controller->PaginatorControllerPost->order = array(
|
||||||
'PaginatorControllerPost.id',
|
'PaginatorControllerPost.id',
|
||||||
'PaginatorControllerPost.created' => 'asc'
|
'PaginatorControllerPost.created' => 'asc'
|
||||||
|
@ -629,6 +638,18 @@ class PaginatorComponentTest extends CakeTestCase {
|
||||||
'PaginatorControllerPost.created' => 'asc'
|
'PaginatorControllerPost.created' => 'asc'
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, $result['order']);
|
$this->assertEquals($expected, $result['order']);
|
||||||
|
|
||||||
|
/* CLASSIC */
|
||||||
|
$Controller->PaginatorControllerPost->order = array(
|
||||||
|
'PaginatorControllerPost.id ASC',
|
||||||
|
'PaginatorControllerPost.created DESC'
|
||||||
|
);
|
||||||
|
$result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array());
|
||||||
|
$expected = array(
|
||||||
|
'PaginatorControllerPost.id' => 'ASC',
|
||||||
|
'PaginatorControllerPost.created' => 'DESC'
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result['order']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue