Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@piwik.org>2018-06-14 00:05:12 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2018-06-14 00:05:12 +0300
commit8b5f334e0deb865af56a3b84133b7a7c1575bb1d (patch)
treeb61e2801da1f69a25ef673fdec3c16bc65e17d72 /tests/PHPUnit
parent8c7a50cb6738232c8da2042e4de14b13fd77eba9 (diff)
Allow to provide secondary sort column for reports (#12128)
* Allow to provide secondy sort column for reports * rename method * Adds two simple tests to prove secondary column sorting * invoke sort callback with datatable as second parameter
Diffstat (limited to 'tests/PHPUnit')
-rw-r--r--tests/PHPUnit/Unit/DataTable/Filter/SortTest.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/DataTable/Filter/SortTest.php b/tests/PHPUnit/Unit/DataTable/Filter/SortTest.php
index 8a405b697a..7474b1cd89 100644
--- a/tests/PHPUnit/Unit/DataTable/Filter/SortTest.php
+++ b/tests/PHPUnit/Unit/DataTable/Filter/SortTest.php
@@ -254,6 +254,34 @@ class SortTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(DataTable::isEqual($table, $expectedtableReverse));
}
+ public function testSecondarySort()
+ {
+ $table = new DataTable();
+ $table->addRowsFromArray(array(
+ array(Row::COLUMNS => array('label' => 'ask', 'count' => 10, 'count2' => 10)),
+ array(Row::COLUMNS => array('label' => 'nintendo', 'count' => 10, 'count2' => 5)),
+ array(Row::COLUMNS => array('label' => 'yahoo', 'count' => 10, 'count2' => 100)
+ )));
+ $filter = new Sort($table, 'count', 'desc', true, true, function(){return 'count2';});
+ $filter->filter($table);
+ $expectedOrder = array('yahoo', 'ask', 'nintendo');
+ $this->assertEquals($expectedOrder, $table->getColumn('label'));
+ }
+
+ public function testSecondarySort2()
+ {
+ $table = new DataTable();
+ $table->addRowsFromArray(array(
+ array(Row::COLUMNS => array('label' => 'ask', 'count' => 1, 'count2' => 10)),
+ array(Row::COLUMNS => array('label' => 'nintendo', 'count' => 10, 'count2' => 5)),
+ array(Row::COLUMNS => array('label' => 'yahoo', 'count' => 10, 'count2' => 100)
+ )));
+ $filter = new Sort($table, 'count', 'desc', true, true, function(){return 'count2';});
+ $filter->filter($table);
+ $expectedOrder = array('yahoo', 'nintendo', 'ask');
+ $this->assertEquals($expectedOrder, $table->getColumn('label'));
+ }
+
private function createDataTable($rows)
{
$table = new DataTable();