/**
* Test to sort by visit
*
* @group Core
*/
public function testFilterSortNumeric()
{
$idcol = Row::COLUMNS;
$table = new DataTable();
$rows = array(array($idcol => array('label' => 'google', 'nb_visits' => 897)), array($idcol => array('label' => 'ask', 'nb_visits' => -152)), array($idcol => array('label' => 'piwik', 'nb_visits' => 1.5)), array($idcol => array('label' => 'yahoo', 'nb_visits' => 154)), array($idcol => array('label' => 'amazon', 'nb_visits' => 30)), array($idcol => array('label' => '238949', 'nb_visits' => 0)), array($idcol => array('label' => 'Q*(%&*', 'nb_visits' => 1)));
$table->addRowsFromArray($rows);
$expectedtable = new DataTable();
$rows = array(array($idcol => array('label' => 'ask', 'nb_visits' => -152)), array($idcol => array('label' => '238949', 'nb_visits' => 0)), array($idcol => array('label' => 'Q*(%&*', 'nb_visits' => 1)), array($idcol => array('label' => 'piwik', 'nb_visits' => 1.5)), array($idcol => array('label' => 'amazon', 'nb_visits' => 30)), array($idcol => array('label' => 'yahoo', 'nb_visits' => 154)), array($idcol => array('label' => 'google', 'nb_visits' => 897)));
$expectedtable->addRowsFromArray($rows);
$expectedtableReverse = new DataTable();
$expectedtableReverse->addRowsFromArray(array_reverse($rows));
$filter = new Sort($table, 'nb_visits', 'asc');
$filter->filter($table);
$this->assertTrue(DataTable::isEqual($table, $expectedtable));
$filter = new Sort($table, 'nb_visits', 'desc');
$filter->filter($table);
$this->assertTrue(DataTable::isEqual($table, $expectedtableReverse));
}