mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
2
e107
2
e107
Submodule e107 updated: e92c6789c5...840859a32f
@@ -122,6 +122,76 @@ class TreeModelTest extends \Codeception\Test\Unit
|
|||||||
$this->assertEquals('163', $tree_model->getParam('db_limit_count'));
|
$this->assertEquals('163', $tree_model->getParam('db_limit_count'));
|
||||||
$this->assertEquals('79', $tree_model->getParam('db_limit_offset'));
|
$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 =
|
protected $sample_rows =
|
||||||
array (
|
array (
|
||||||
1 =>
|
1 =>
|
||||||
|
Reference in New Issue
Block a user