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:
authormattab <matthieu.aubry@gmail.com>2013-07-21 12:01:35 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-21 12:01:36 +0400
commitaca8ec33a85e0a70b818b6227145041717d7a69e (patch)
tree41377e3a9737d63222522ef93ecf8483f3faddfa /tests/PHPUnit/Core/DataTable/Filter/SortTest.php
parent0a63210e3eae7562af1a3dbee340eb1ee140db3d (diff)
Refs #4059 Work in progress: Conversion to use Namespaces: Period*, Metrics, Segment, SegmentExpression, PluginsManager.
Removed some deprecated code.
Diffstat (limited to 'tests/PHPUnit/Core/DataTable/Filter/SortTest.php')
-rw-r--r--tests/PHPUnit/Core/DataTable/Filter/SortTest.php84
1 files changed, 44 insertions, 40 deletions
diff --git a/tests/PHPUnit/Core/DataTable/Filter/SortTest.php b/tests/PHPUnit/Core/DataTable/Filter/SortTest.php
index eb793bd136..204d98f432 100644
--- a/tests/PHPUnit/Core/DataTable/Filter/SortTest.php
+++ b/tests/PHPUnit/Core/DataTable/Filter/SortTest.php
@@ -5,6 +5,10 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\DataTable;
+use Piwik\DataTable\Filter\Sort;
+use Piwik\DataTable\Row;
+
class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
{
/**
@@ -16,13 +20,13 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
*/
public function testNormalSortDescending()
{
- $table = new Piwik_DataTable();
+ $table = new DataTable();
$table->addRowsFromArray(array(
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'count' => 100)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nintendo', 'count' => 0)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo', 'count' => 10)
+ array(Row::COLUMNS => array('label' => 'ask', 'count' => 100)),
+ array(Row::COLUMNS => array('label' => 'nintendo', 'count' => 0)),
+ array(Row::COLUMNS => array('label' => 'yahoo', 'count' => 10)
)));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'count', 'desc');
+ $filter = new Sort($table, 'count', 'desc');
$filter->filter($table);
$expectedOrder = array('ask', 'yahoo', 'nintendo');
$this->assertEquals($expectedOrder, $table->getColumn('label'));
@@ -37,13 +41,13 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
*/
public function testNormalSortAscending()
{
- $table = new Piwik_DataTable();
+ $table = new DataTable();
$table->addRowsFromArray(array(
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'count' => 100.5)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nintendo', 'count' => 0.5)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo', 'count' => 10.5)
+ array(Row::COLUMNS => array('label' => 'ask', 'count' => 100.5)),
+ array(Row::COLUMNS => array('label' => 'nintendo', 'count' => 0.5)),
+ array(Row::COLUMNS => array('label' => 'yahoo', 'count' => 10.5)
)));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'count', 'asc');
+ $filter = new Sort($table, 'count', 'asc');
$filter->filter($table);
$expectedOrder = array('nintendo', 'yahoo', 'ask');
$this->assertEquals($expectedOrder, $table->getColumn('label'));
@@ -58,16 +62,16 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
*/
public function testMissingColumnValuesShouldAppearLastAfterSortAsc()
{
- $table = new Piwik_DataTable();
+ $table = new DataTable();
$table->addRowsFromArray(array(
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nintendo', 'count' => 1)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nocolumn')),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nocolumnbis')),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'count' => 2)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'amazing')),
- Piwik_DataTable::ID_SUMMARY_ROW => array(Piwik_DataTable_Row::COLUMNS => array('label' => 'summary', 'count' => 10)
+ array(Row::COLUMNS => array('label' => 'nintendo', 'count' => 1)),
+ array(Row::COLUMNS => array('label' => 'nocolumn')),
+ array(Row::COLUMNS => array('label' => 'nocolumnbis')),
+ array(Row::COLUMNS => array('label' => 'ask', 'count' => 2)),
+ array(Row::COLUMNS => array('label' => 'amazing')),
+ DataTable::ID_SUMMARY_ROW => array(Row::COLUMNS => array('label' => 'summary', 'count' => 10)
)));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'count', 'asc');
+ $filter = new Sort($table, 'count', 'asc');
$filter->filter($table);
$expectedOrder = array('nintendo', 'ask', 'amazing', 'nocolumnbis', 'nocolumn', 'summary');
$this->assertEquals($expectedOrder, $table->getColumn('label'));
@@ -82,14 +86,14 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
*/
public function testMissingColumnValuesShouldAppearLastAfterSortDesc()
{
- $table = new Piwik_DataTable();
+ $table = new DataTable();
$table->addRowsFromArray(array(
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nintendo', 'count' => 1)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'count' => 2)),
- array(Piwik_DataTable_Row::COLUMNS => array('label' => 'amazing')),
- Piwik_DataTable::ID_SUMMARY_ROW => array(Piwik_DataTable_Row::COLUMNS => array('label' => 'summary', 'count' => 10)
+ array(Row::COLUMNS => array('label' => 'nintendo', 'count' => 1)),
+ array(Row::COLUMNS => array('label' => 'ask', 'count' => 2)),
+ array(Row::COLUMNS => array('label' => 'amazing')),
+ DataTable::ID_SUMMARY_ROW => array(Row::COLUMNS => array('label' => 'summary', 'count' => 10)
)));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'count', 'desc');
+ $filter = new Sort($table, 'count', 'desc');
$filter->filter($table);
$expectedOrder = array('ask', 'nintendo', 'amazing', 'summary');
$this->assertEquals($expectedOrder, $table->getColumn('label'));
@@ -105,8 +109,8 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
*/
public function testFilterSortString()
{
- $idcol = Piwik_DataTable_Row::COLUMNS;
- $table = new Piwik_DataTable();
+ $idcol = Row::COLUMNS;
+ $table = new DataTable();
$rows = array(
array($idcol => array('label' => 'google')), //0
array($idcol => array('label' => 'ask')), //1
@@ -117,7 +121,7 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
array($idcol => array('label' => 'Q*(%&*("$&%*(&"$*")"))')) //6
);
$table->addRowsFromArray($rows);
- $expectedtable = new Piwik_DataTable();
+ $expectedtable = new DataTable();
$rows = array(
array($idcol => array('label' => '238975247578949')), //5
array($idcol => array('label' => 'amazon')), //4
@@ -128,16 +132,16 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
array($idcol => array('label' => 'yahoo')) //3
);
$expectedtable->addRowsFromArray($rows);
- $expectedtableReverse = new Piwik_DataTable();
+ $expectedtableReverse = new DataTable();
$expectedtableReverse->addRowsFromArray(array_reverse($rows));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'label', 'asc');
+ $filter = new Sort($table, 'label', 'asc');
$filter->filter($table);
- $this->assertTrue(Piwik_DataTable::isEqual($expectedtable, $table));
+ $this->assertTrue(DataTable::isEqual($expectedtable, $table));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'label', 'desc');
+ $filter = new Sort($table, 'label', 'desc');
$filter->filter($table);
- $this->assertTrue(Piwik_DataTable::isEqual($table, $expectedtableReverse));
+ $this->assertTrue(DataTable::isEqual($table, $expectedtableReverse));
}
/**
@@ -150,8 +154,8 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
*/
public function testFilterSortNumeric()
{
- $idcol = Piwik_DataTable_Row::COLUMNS;
- $table = new Piwik_DataTable();
+ $idcol = Row::COLUMNS;
+ $table = new DataTable();
$rows = array(
array($idcol => array('label' => 'google', 'nb_visits' => 897)), //0
array($idcol => array('label' => 'ask', 'nb_visits' => -152)), //1
@@ -162,7 +166,7 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
array($idcol => array('label' => 'Q*(%&*', 'nb_visits' => 1)) //6
);
$table->addRowsFromArray($rows);
- $expectedtable = new Piwik_DataTable();
+ $expectedtable = new DataTable();
$rows = array(
array($idcol => array('label' => 'ask', 'nb_visits' => -152)), //1
array($idcol => array('label' => '238949', 'nb_visits' => 0)), //5
@@ -173,15 +177,15 @@ class DataTable_Filter_SortTest extends PHPUnit_Framework_TestCase
array($idcol => array('label' => 'google', 'nb_visits' => 897)) //0
);
$expectedtable->addRowsFromArray($rows);
- $expectedtableReverse = new Piwik_DataTable();
+ $expectedtableReverse = new DataTable();
$expectedtableReverse->addRowsFromArray(array_reverse($rows));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'nb_visits', 'asc');
+ $filter = new Sort($table, 'nb_visits', 'asc');
$filter->filter($table);
- $this->assertTrue(Piwik_DataTable::isEqual($table, $expectedtable));
+ $this->assertTrue(DataTable::isEqual($table, $expectedtable));
- $filter = new Piwik_DataTable_Filter_Sort($table, 'nb_visits', 'desc');
+ $filter = new Sort($table, 'nb_visits', 'desc');
$filter->filter($table);
- $this->assertTrue(Piwik_DataTable::isEqual($table, $expectedtableReverse));
+ $this->assertTrue(DataTable::isEqual($table, $expectedtableReverse));
}
}