|
|
|
@ -53,6 +53,9 @@ class SortTest extends TestCase
|
|
|
|
|
$this->assertEquals(SORT_ASC, $orders['age']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testGetOrders |
|
|
|
|
*/ |
|
|
|
|
public function testGetAttributeOrders() |
|
|
|
|
{ |
|
|
|
|
$sort = new Sort([ |
|
|
|
@ -80,6 +83,9 @@ class SortTest extends TestCase
|
|
|
|
|
$this->assertEquals(SORT_ASC, $orders['age']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testGetAttributeOrders |
|
|
|
|
*/ |
|
|
|
|
public function testGetAttributeOrder() |
|
|
|
|
{ |
|
|
|
|
$sort = new Sort([ |
|
|
|
@ -101,6 +107,45 @@ class SortTest extends TestCase
|
|
|
|
|
$this->assertNull($sort->getAttributeOrder('xyz')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testGetAttributeOrders |
|
|
|
|
*/ |
|
|
|
|
public function testSetAttributeOrders() |
|
|
|
|
{ |
|
|
|
|
$sort = new Sort([ |
|
|
|
|
'attributes' => [ |
|
|
|
|
'age', |
|
|
|
|
'name' => [ |
|
|
|
|
'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], |
|
|
|
|
'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], |
|
|
|
|
], |
|
|
|
|
], |
|
|
|
|
'params' => [ |
|
|
|
|
'sort' => 'age,-name' |
|
|
|
|
], |
|
|
|
|
'enableMultiSort' => true, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$orders = [ |
|
|
|
|
'age' => SORT_DESC, |
|
|
|
|
'name' => SORT_ASC, |
|
|
|
|
]; |
|
|
|
|
$sort->setAttributeOrders($orders); |
|
|
|
|
$this->assertEquals($orders, $sort->getAttributeOrders()); |
|
|
|
|
|
|
|
|
|
$sort->enableMultiSort = false; |
|
|
|
|
$sort->setAttributeOrders($orders); |
|
|
|
|
$this->assertEquals(['age' => SORT_DESC], $sort->getAttributeOrders()); |
|
|
|
|
$sort->setAttributeOrders($orders, false); |
|
|
|
|
$this->assertEquals($orders, $sort->getAttributeOrders()); |
|
|
|
|
|
|
|
|
|
$orders = ['unexistingAttribute' => SORT_ASC]; |
|
|
|
|
$sort->setAttributeOrders($orders); |
|
|
|
|
$this->assertEquals([], $sort->getAttributeOrders()); |
|
|
|
|
$sort->setAttributeOrders($orders, false); |
|
|
|
|
$this->assertEquals($orders, $sort->getAttributeOrders()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testCreateSortParam() |
|
|
|
|
{ |
|
|
|
|
$sort = new Sort([ |
|
|
|
@ -150,6 +195,9 @@ class SortTest extends TestCase
|
|
|
|
|
$this->assertEquals('/index.php?r=site%2Findex&sort=name%2Cage', $sort->createUrl('name')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testCreateUrl |
|
|
|
|
*/ |
|
|
|
|
public function testLink() |
|
|
|
|
{ |
|
|
|
|
$this->mockApplication(); |
|
|
|
|