diff options
Diffstat (limited to 'tests/PHPUnit/Core/DataTable/Filter/LimitTest.php')
-rw-r--r-- | tests/PHPUnit/Core/DataTable/Filter/LimitTest.php | 224 |
1 files changed, 112 insertions, 112 deletions
diff --git a/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php b/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php index ccd2a17577..37a9e20d58 100644 --- a/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php +++ b/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php @@ -17,23 +17,23 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $table = new Piwik_DataTable; $idcol = Piwik_DataTable_Row::COLUMNS; $rows = array( - array($idcol => array('label'=> 'google', 'idRow' => 0)), - array($idcol => array('label'=> 'ask', 'idRow' => 1)), - array($idcol => array('label'=> 'piwik', 'idRow' => 2)), - array($idcol => array('label'=> 'yahoo', 'idRow' => 3)), - array($idcol => array('label'=> 'amazon', 'idRow' => 4)), - array($idcol => array('label'=> '238949', 'idRow' => 5)), - array($idcol => array('label'=> 'test', 'idRow' => 6)), - array($idcol => array('label'=> 'amazing', 'idRow' => 7)), - array($idcol => array('label'=> 'great', 'idRow' => 8)), - Piwik_DataTable::ID_SUMMARY_ROW => array($idcol => array('label'=> 'summary row', 'idRow' => 9)), + array($idcol => array('label' => 'google', 'idRow' => 0)), + array($idcol => array('label' => 'ask', 'idRow' => 1)), + array($idcol => array('label' => 'piwik', 'idRow' => 2)), + array($idcol => array('label' => 'yahoo', 'idRow' => 3)), + array($idcol => array('label' => 'amazon', 'idRow' => 4)), + array($idcol => array('label' => '238949', 'idRow' => 5)), + array($idcol => array('label' => 'test', 'idRow' => 6)), + array($idcol => array('label' => 'amazing', 'idRow' => 7)), + array($idcol => array('label' => 'great', 'idRow' => 8)), + Piwik_DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => 'summary row', 'idRow' => 9)), ); - $table->addRowsFromArray( $rows ); + $table->addRowsFromArray($rows); return $table; } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -51,9 +51,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(4, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -71,9 +71,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(8, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -92,9 +92,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(9, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -113,9 +113,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(9, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -132,9 +132,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(9, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -152,9 +152,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(9, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -174,7 +174,7 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase } /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -192,9 +192,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(9, $table->getLastRow()->getColumn('idRow')); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -210,9 +210,9 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(0, $table->getRowsCount()); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -228,10 +228,10 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $this->assertEquals(0, $table->getRowsCount()); $this->assertEquals(10, $table->getRowsCountBeforeLimitFilter()); } - + /** * Test to filter a table with a offset, limit - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -240,37 +240,37 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase public function testFilterOffsetLimit() { $table = new Piwik_DataTable; - + $idcol = Piwik_DataTable_Row::COLUMNS; - + $rows = array( - array( $idcol => array('label'=>'google')),//0 - array( $idcol => array('label'=>'ask')),//1 - array( $idcol => array('label'=>'piwik')),//2 - array( $idcol => array('label'=>'yahoo')),//3 - array( $idcol => array('label'=>'amazon')),//4 - array( $idcol => array('label'=>'238975247578949')),//5 - array( $idcol => array('label'=>'Q*(%&*("$&%*(&"$*")"))'))//6 + array($idcol => array('label' => 'google')), //0 + array($idcol => array('label' => 'ask')), //1 + array($idcol => array('label' => 'piwik')), //2 + array($idcol => array('label' => 'yahoo')), //3 + array($idcol => array('label' => 'amazon')), //4 + array($idcol => array('label' => '238975247578949')), //5 + array($idcol => array('label' => 'Q*(%&*("$&%*(&"$*")"))')) //6 ); - - $table->addRowsFromArray( $rows ); - + + $table->addRowsFromArray($rows); + $expectedtable = clone $table; - $expectedtable->deleteRows(array(0,1,6)); - + $expectedtable->deleteRows(array(0, 1, 6)); + $filter = new Piwik_DataTable_Filter_Limit($table, 2, 4); $filter->filter($table); - - $colAfter=$colExpected=array(); - foreach($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - + + $colAfter = $colExpected = array(); + foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); + foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); + $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } - + /** * Test to filter a column with a offset, limit off bound - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -279,37 +279,37 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase public function testFilterOffsetLimitOffbound() { $table = new Piwik_DataTable; - + $idcol = Piwik_DataTable_Row::COLUMNS; - + $rows = array( - array( $idcol => array('label'=>'google')),//0 - array( $idcol => array('label'=>'ask')),//1 - array( $idcol => array('label'=>'piwik')),//2 - array( $idcol => array('label'=>'yahoo')),//3 - array( $idcol => array('label'=>'amazon')),//4 - array( $idcol => array('label'=>'238975247578949')),//5 - array( $idcol => array('label'=>'Q*(%&*("$&%*(&"$*")"))'))//6 + array($idcol => array('label' => 'google')), //0 + array($idcol => array('label' => 'ask')), //1 + array($idcol => array('label' => 'piwik')), //2 + array($idcol => array('label' => 'yahoo')), //3 + array($idcol => array('label' => 'amazon')), //4 + array($idcol => array('label' => '238975247578949')), //5 + array($idcol => array('label' => 'Q*(%&*("$&%*(&"$*")"))')) //6 ); - - $table->addRowsFromArray( $rows ); - + + $table->addRowsFromArray($rows); + $expectedtable = clone $table; - $expectedtable->deleteRows(array(0,1,3,4,5,6)); - + $expectedtable->deleteRows(array(0, 1, 3, 4, 5, 6)); + $filter = new Piwik_DataTable_Filter_Limit($table, 2, 1); $filter->filter($table); - - $colAfter=$colExpected=array(); - foreach($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - + + $colAfter = $colExpected = array(); + foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); + foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); + $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } - + /** * Test to filter a column with a offset, limit 2 - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -318,36 +318,36 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase public function testFilterOffsetLimit2() { $table = new Piwik_DataTable; - + $idcol = Piwik_DataTable_Row::COLUMNS; - + $rows = array( - array( $idcol => array('label'=>'google')),//0 - array( $idcol => array('label'=>'ask')),//1 - array( $idcol => array('label'=>'piwik')),//2 - array( $idcol => array('label'=>'yahoo')),//3 - array( $idcol => array('label'=>'amazon')),//4 - array( $idcol => array('label'=>'238975247578949')),//5 - array( $idcol => array('label'=>'Q*(%&*("$&%*(&"$*")"))'))//6 + array($idcol => array('label' => 'google')), //0 + array($idcol => array('label' => 'ask')), //1 + array($idcol => array('label' => 'piwik')), //2 + array($idcol => array('label' => 'yahoo')), //3 + array($idcol => array('label' => 'amazon')), //4 + array($idcol => array('label' => '238975247578949')), //5 + array($idcol => array('label' => 'Q*(%&*("$&%*(&"$*")"))')) //6 ); - - $table->addRowsFromArray( $rows ); - + + $table->addRowsFromArray($rows); + $expectedtable = clone $table; - + $filter = new Piwik_DataTable_Filter_Limit($table, 0, 15); $filter->filter($table); - - $colAfter=$colExpected=array(); - foreach($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - + + $colAfter = $colExpected = array(); + foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); + foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); + $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } - + /** * Test to filter a column with a offset, limit 3 - * + * * @group Core * @group DataTable * @group DataTable_Filter @@ -356,31 +356,31 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase public function testFilterOffsetLimit3() { $table = new Piwik_DataTable; - + $idcol = Piwik_DataTable_Row::COLUMNS; - + $rows = array( - array( $idcol => array('label'=>'google')),//0 - array( $idcol => array('label'=>'ask')),//1 - array( $idcol => array('label'=>'piwik')),//2 - array( $idcol => array('label'=>'yahoo')),//3 - array( $idcol => array('label'=>'amazon')),//4 - array( $idcol => array('label'=>'238975247578949')),//5 - array( $idcol => array('label'=>'Q*(%&*("$&%*(&"$*")"))'))//6 + array($idcol => array('label' => 'google')), //0 + array($idcol => array('label' => 'ask')), //1 + array($idcol => array('label' => 'piwik')), //2 + array($idcol => array('label' => 'yahoo')), //3 + array($idcol => array('label' => 'amazon')), //4 + array($idcol => array('label' => '238975247578949')), //5 + array($idcol => array('label' => 'Q*(%&*("$&%*(&"$*")"))')) //6 ); - - $table->addRowsFromArray( $rows ); + + $table->addRowsFromArray($rows); $expectedtable = new Piwik_DataTable; - + $filter = new Piwik_DataTable_Filter_Limit($table, 8, 15); $filter->filter($table); - - $colAfter=$colExpected=array(); - foreach($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - + + $colAfter = $colExpected = array(); + foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); + foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); + $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } - + } |