mirror of
https://github.com/e107inc/e107.git
synced 2025-04-07 22:23:09 +02:00
Test e_tree_model::multiFieldCmp()
Relates to: 840859a32f5e7c6d579f1b643e99ed30d30d1fd7
This commit is contained in:
parent
8b07f620f1
commit
986b4a63ba
2
e107
2
e107
@ -1 +1 @@
|
||||
Subproject commit e92c6789c51c9b653153efe555d1ded9ffbff49f
|
||||
Subproject commit 840859a32f5e7c6d579f1b643e99ed30d30d1fd7
|
@ -122,6 +122,76 @@ class TreeModelTest extends \Codeception\Test\Unit
|
||||
$this->assertEquals('163', $tree_model->getParam('db_limit_count'));
|
||||
$this->assertEquals('79', $tree_model->getParam('db_limit_offset'));
|
||||
}
|
||||
|
||||
public function testMultiFieldCompareWithSortFieldsReturnsExpectedValues()
|
||||
{
|
||||
$tree_model = $this->make('e_tree_model');
|
||||
$class = new \ReflectionClass(get_class($tree_model));
|
||||
$method = $class->getMethod('multiFieldCmp');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$row1 = array(
|
||||
'field1' => '0',
|
||||
'field2' => '-1',
|
||||
);
|
||||
$row2 = array(
|
||||
'field1' => '0',
|
||||
'field2' => '1',
|
||||
);
|
||||
$sort_fields = ['field1', 'field2'];
|
||||
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
|
||||
$this->assertEquals(-1, $result);
|
||||
|
||||
$row1['field2'] = 1;
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
|
||||
$this->assertEquals(0, $result);
|
||||
|
||||
$row1['field2'] = 2;
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
$row1['field1'] = -1;
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
|
||||
$this->assertEquals(-1, $result);
|
||||
|
||||
$row1['field1'] = 1;
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_fields, 1);
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
|
||||
public function testMultiFieldCompareWithSortFieldReturnsExpectedValues()
|
||||
{
|
||||
$tree_model = $this->make('e_tree_model');
|
||||
$class = new \ReflectionClass(get_class($tree_model));
|
||||
$method = $class->getMethod('multiFieldCmp');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$row1 = array(
|
||||
'field1' => '0',
|
||||
'field2' => '-1',
|
||||
);
|
||||
$row2 = array(
|
||||
'field1' => '0',
|
||||
'field2' => '1',
|
||||
);
|
||||
$sort_field = 'field1';
|
||||
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_field, 1);
|
||||
$this->assertEquals(0, $result);
|
||||
|
||||
$row1['field1'] = -1;
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_field, 1);
|
||||
$this->assertEquals(-1, $result);
|
||||
|
||||
$row1['field1'] = 1;
|
||||
$result = $method->invoke(null, $row1, $row2, $sort_field, 1);
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
$row1['field2'] = 1337;
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
|
||||
protected $sample_rows =
|
||||
array (
|
||||
1 =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user