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:
Diffstat (limited to 'tests/PHPUnit/Core/DataTable/Filter/AddSummaryRowTest.php')
-rw-r--r--tests/PHPUnit/Core/DataTable/Filter/AddSummaryRowTest.php78
1 files changed, 41 insertions, 37 deletions
diff --git a/tests/PHPUnit/Core/DataTable/Filter/AddSummaryRowTest.php b/tests/PHPUnit/Core/DataTable/Filter/AddSummaryRowTest.php
index 5071d2b815..05136a1c27 100644
--- a/tests/PHPUnit/Core/DataTable/Filter/AddSummaryRowTest.php
+++ b/tests/PHPUnit/Core/DataTable/Filter/AddSummaryRowTest.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\AddSummaryRow;
+use Piwik\DataTable\Row;
+
class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
{
/**
@@ -17,10 +21,10 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
public function testOffsetIsCountSummaryRowShouldBeTheRow()
{
$table = $this->getDataTableCount5();
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table, 5);
+ $filter = new AddSummaryRow($table, 5);
$filter->filter($table);
$this->assertEquals(5, $table->getRowsCount());
- $this->assertTrue(Piwik_DataTable_Row::isEqual($table->getLastRow(), $this->getRow4()));
+ $this->assertTrue(Row::isEqual($table->getLastRow(), $this->getRow4()));
}
/**
@@ -33,11 +37,11 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
public function testOffsetIsLessThanCountSummaryRowShouldBeTheSum()
{
$table = $this->getDataTableCount5();
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table, 2);
+ $filter = new AddSummaryRow($table, 2);
$filter->filter($table);
$this->assertEquals(3, $table->getRowsCount());
- $expectedRow = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => Piwik_DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
- $this->assertTrue(Piwik_DataTable_Row::isEqual($table->getLastRow(), $expectedRow));
+ $expectedRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
+ $this->assertTrue(Row::isEqual($table->getLastRow(), $expectedRow));
// check that column 'label' is forced to be first in summary row
$this->assertEquals(array_keys($table->getLastRow()->getColumns()), array_keys($expectedRow->getColumns()));
}
@@ -52,10 +56,10 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
public function testOffsetIsMoreThanCountShouldNotAddSummaryRow()
{
$table = $this->getDataTableCount5();
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table, 6);
+ $filter = new AddSummaryRow($table, 6);
$filter->filter($table);
$this->assertEquals(5, $table->getRowsCount());
- $this->assertTrue(Piwik_DataTable_Row::isEqual($table->getLastRow(), $this->getRow4()));
+ $this->assertTrue(Row::isEqual($table->getLastRow(), $this->getRow4()));
}
/**
@@ -68,13 +72,13 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
public function testWhenThereIsAlreadyASummaryRowShouldReplaceTheSummaryRow()
{
$table = $this->getDataTableCount5();
- $filter1 = new Piwik_DataTable_Filter_AddSummaryRow($table, 3);
+ $filter1 = new AddSummaryRow($table, 3);
$filter1->filter($table);
- $filter2 = new Piwik_DataTable_Filter_AddSummaryRow($table, 2);
+ $filter2 = new AddSummaryRow($table, 2);
$filter2->filter($table);
$this->assertEquals(3, $table->getRowsCount());
- $expectedRow = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => Piwik_DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
- $this->assertTrue(Piwik_DataTable_Row::isEqual($table->getLastRow(), $expectedRow));
+ $expectedRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
+ $this->assertTrue(Row::isEqual($table->getLastRow(), $expectedRow));
}
/**
@@ -88,23 +92,23 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
{
// row0, row1, row2, rowSummary1
$table1 = $this->getDataTableCount5();
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table1, 3);
+ $filter = new AddSummaryRow($table1, 3);
$filter->filter($table1);
// row0, row1, rowSummary2
$table2 = $this->getDataTableCount5();
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table2, 2);
+ $filter = new AddSummaryRow($table2, 2);
$filter->filter($table2);
// we expect row0+row0, row1+row1, row2, rowSummary1+rowSummary2
- $expectedTable = new Piwik_DataTable;
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'amazon', 'nb' => 20000))));
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo', 'nb' => 2000))));
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'piwik', 'nb' => 100))));
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => Piwik_DataTable::LABEL_SUMMARY_ROW, 'nb' => 122))));
+ $expectedTable = new DataTable;
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => 'amazon', 'nb' => 20000))));
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => 'yahoo', 'nb' => 2000))));
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => 'piwik', 'nb' => 100))));
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 122))));
$table1->addDataTable($table2);
- $this->assertTrue(Piwik_DataTable::isEqual($expectedTable, $table1));
+ $this->assertTrue(DataTable::isEqual($expectedTable, $table1));
}
/**
@@ -118,23 +122,23 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
{
// row0, row1, row2, rowSummary1
$table1 = $this->getDataTableCount5();
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table1, 3);
+ $filter = new AddSummaryRow($table1, 3);
$filter->filter($table1);
// row0, row1, row2, row3, row4
$table2 = $this->getDataTableCount5();
// we expect row0+row0, row1+row1, row2+row2, row3, row4, rowSummary1
- $expectedTable = new Piwik_DataTable;
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'amazon', 'nb' => 20000))));
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo', 'nb' => 2000))));
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'piwik', 'nb' => 200))));
+ $expectedTable = new DataTable;
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => 'amazon', 'nb' => 20000))));
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => 'yahoo', 'nb' => 2000))));
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => 'piwik', 'nb' => 200))));
$expectedTable->addRow($this->getRow3());
$expectedTable->addRow($this->getRow4());
- $expectedTable->addRow(new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => Piwik_DataTable::LABEL_SUMMARY_ROW, 'nb' => 11))));
+ $expectedTable->addRow(new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 11))));
$table1->addDataTable($table2);
- $this->assertTrue(Piwik_DataTable::isEqual($expectedTable, $table1));
+ $this->assertTrue(DataTable::isEqual($expectedTable, $table1));
}
@@ -147,28 +151,28 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
*/
public function testWhenRowsInRandomOrderButSortSpecifiedShouldComputeSummaryRowAfterSort()
{
- $table = new Piwik_DataTable;
+ $table = new DataTable;
$table->addRow($this->getRow3());
$table->addRow($this->getRow2());
$table->addRow($this->getRow4());
$table->addRow($this->getRow1());
$table->addRow($this->getRow0());
- $filter = new Piwik_DataTable_Filter_AddSummaryRow($table, 2, Piwik_DataTable::LABEL_SUMMARY_ROW, $columnToSortBy = 'nb');
+ $filter = new AddSummaryRow($table, 2, DataTable::LABEL_SUMMARY_ROW, $columnToSortBy = 'nb');
$filter->filter($table);
$this->assertEquals(3, $table->getRowsCount());
- $expectedRow = new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => Piwik_DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
- $this->assertTrue(Piwik_DataTable_Row::isEqual($table->getLastRow(), $expectedRow));
+ $expectedRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
+ $this->assertTrue(Row::isEqual($table->getLastRow(), $expectedRow));
}
/**
* Returns table used for the tests
*
- * @return Piwik_DataTable
+ * @return DataTable
*/
protected function getDataTableCount5()
{
- $table = new Piwik_DataTable;
+ $table = new DataTable;
$table->addRow($this->getRow0());
$table->addRow($this->getRow1());
$table->addRow($this->getRow2());
@@ -179,26 +183,26 @@ class DataTable_Filter_AddSummaryRowTest extends PHPUnit_Framework_TestCase
protected function getRow0()
{
- return new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('nb' => 10000, 'label' => 'amazon')));
+ return new Row(array(Row::COLUMNS => array('nb' => 10000, 'label' => 'amazon')));
}
protected function getRow1()
{
- return new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo', 'nb' => 1000)));
+ return new Row(array(Row::COLUMNS => array('label' => 'yahoo', 'nb' => 1000)));
}
protected function getRow2()
{
- return new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'piwik', 'nb' => 100)));
+ return new Row(array(Row::COLUMNS => array('label' => 'piwik', 'nb' => 100)));
}
protected function getRow3()
{
- return new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'nb' => 10)));
+ return new Row(array(Row::COLUMNS => array('label' => 'ask', 'nb' => 10)));
}
protected function getRow4()
{
- return new Piwik_DataTable_Row(array(Piwik_DataTable_Row::COLUMNS => array('nb' => 1, 'label' => 'google')));
+ return new Row(array(Row::COLUMNS => array('nb' => 1, 'label' => 'google')));
}
}