當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataTable::isEqual方法代碼示例

本文整理匯總了PHP中Piwik\DataTable::isEqual方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataTable::isEqual方法的具體用法?PHP DataTable::isEqual怎麽用?PHP DataTable::isEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Piwik\DataTable的用法示例。


在下文中一共展示了DataTable::isEqual方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFilterLowpop1

 /**
  * Test to exclude low population filter
  *
  * @group Core
  */
 public function testFilterLowpop1()
 {
     $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' => 'piwik2', 'nb_visits' => 1.4)), 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)), array($idcol => array('label' => 'Q*(%&*2', 'nb_visits' => -1.5)));
     $table->addRowsFromArray($rows);
     $expectedtable = new DataTable();
     $rows = array(array($idcol => array('label' => 'google', 'nb_visits' => 897)), array($idcol => array('label' => 'piwik', 'nb_visits' => 1.5)), array($idcol => array('label' => 'piwik2', 'nb_visits' => 1.4)), array($idcol => array('label' => 'yahoo', 'nb_visits' => 154)), array($idcol => array('label' => 'amazon', 'nb_visits' => 30)));
     $expectedtable->addRowsFromArray($rows);
     $filter = new ExcludeLowPopulation($table, 'nb_visits', 1.4);
     $filter->filter($table);
     $this->assertTrue(DataTable::isEqual($table, $expectedtable));
 }
開發者ID:carriercomm,項目名稱:piwik,代碼行數:18,代碼來源:ExcludeLowPopulationTest.php

示例2: testAddOneTableWithSummaryRow

 public function testAddOneTableWithSummaryRow()
 {
     // row0, row1, row2, rowSummary1
     $table1 = $this->getDataTableCount5();
     $filter = new Truncate($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 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 Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 11))));
     $table1->addDataTable($table2);
     $this->assertTrue(DataTable::isEqual($expectedTable, $table1));
 }
開發者ID:mgou-net,項目名稱:piwik,代碼行數:19,代碼來源:TruncateTest.php

示例3: testAddDataTable2times

 /**
  * test add 2 different tables to the same table
  */
 public function testAddDataTable2times()
 {
     $idcol = Row::COLUMNS;
     $rows = array(array($idcol => array('label' => 'google', 'visits' => 1)), array($idcol => array('label' => 'ask', 'visits' => 0)), array($idcol => array('label' => '123', 'visits' => 2)), DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => DataTable::LABEL_SUMMARY_ROW, 'visits' => 1)));
     $table = new DataTable();
     $table->addRowsFromArray($rows);
     $rows2 = array(array($idcol => array('label' => 'google2', 'visits' => -1)), array($idcol => array('label' => 'ask', 'visits' => 100)), array($idcol => array('label' => '123456', 'visits' => 1.5)));
     $table2 = new DataTable();
     $table2->addRowsFromArray($rows2);
     $rows3 = array(array($idcol => array('label' => 'google2', 'visits' => -1)), array($idcol => array('label' => 'ask', 'visits' => -10)), array($idcol => array('label' => '123ab', 'visits' => 1.5)), DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => DataTable::LABEL_SUMMARY_ROW, 'visits' => 3)));
     $table3 = new DataTable();
     $table3->addRowsFromArray($rows3);
     // add the 2 tables
     $table->addDataTable($table2);
     $table->addDataTable($table3);
     $rowsExpected = array(array($idcol => array('label' => 'google', 'visits' => 1)), array($idcol => array('label' => 'ask', 'visits' => 90)), array($idcol => array('label' => '123', 'visits' => 2)), array($idcol => array('label' => 'google2', 'visits' => -2)), array($idcol => array('label' => '123456', 'visits' => 1.5)), array($idcol => array('label' => '123ab', 'visits' => 1.5)), DataTable::ID_SUMMARY_ROW => array($idcol => array('label' => DataTable::LABEL_SUMMARY_ROW, 'visits' => 4)));
     $tableExpected = new DataTable();
     $tableExpected->addRowsFromArray($rowsExpected);
     $this->assertTrue(DataTable::isEqual($table, $tableExpected));
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:23,代碼來源:DataTableTest.php

示例4: isEqual

 /**
  * Helper function that tests if two rows are equal.
  *
  * Two rows are equal if:
  *
  * - they have exactly the same columns / metadata
  * - they have a subDataTable associated, then we check that both of them are the same.
  *
  * Column order is not important.
  *
  * @param \Piwik\DataTable\Row $row1 first to compare
  * @param \Piwik\DataTable\Row $row2 second to compare
  * @return bool
  */
 public static function isEqual(Row $row1, Row $row2)
 {
     //same columns
     $cols1 = $row1->getColumns();
     $cols2 = $row2->getColumns();
     $diff1 = array_udiff($cols1, $cols2, array(__CLASS__, 'compareElements'));
     $diff2 = array_udiff($cols2, $cols1, array(__CLASS__, 'compareElements'));
     if ($diff1 != $diff2) {
         return false;
     }
     $dets1 = $row1->getMetadata();
     $dets2 = $row2->getMetadata();
     ksort($dets1);
     ksort($dets2);
     if ($dets1 != $dets2) {
         return false;
     }
     // either both are null
     // or both have a value
     if (!(is_null($row1->getIdSubDataTable()) && is_null($row2->getIdSubDataTable()))) {
         $subtable1 = $row1->getSubtable();
         $subtable2 = $row2->getSubtable();
         if (!DataTable::isEqual($subtable1, $subtable2)) {
             return false;
         }
     }
     return true;
 }
開發者ID:josl,項目名稱:CGE-File-Sharing,代碼行數:42,代碼來源:Row.php

示例5: testFilterSortNumeric

 /**
  * 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));
 }
開發者ID:carriercomm,項目名稱:piwik,代碼行數:23,代碼來源:SortTest.php

示例6: test_sortingArrayValues_doesNotError

 public function test_sortingArrayValues_doesNotError()
 {
     $table = new DataTable();
     $table->addRowsFromArray(array(array(Row::COLUMNS => array('label' => 'ask', 'count_array' => array(100, 1, 2))), array(Row::COLUMNS => array('label' => 'nintendo', 'count_array' => array(0, 'hello'))), array(Row::COLUMNS => array('label' => 'yahoo', 'count_array' => array(10, 'test')))));
     $tableOriginal = clone $table;
     $filter = new Sort($table, 'count_array', 'desc');
     $filter->filter($table);
     $this->assertTrue(DataTable::isEqual($tableOriginal, $table));
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:9,代碼來源:SortTest.php

示例7: test_sumSubTable_whenSubTableAlreadyExists_overwriteExistingSubtable

 public function test_sumSubTable_whenSubTableAlreadyExists_overwriteExistingSubtable()
 {
     $testRow = $this->getTestRowWithSubDataTableNotLoaded();
     $this->assertFalse($testRow->isSubtableLoaded());
     $subTable = $this->getTestSubDataTable();
     $testRow->setSubtable($subTable);
     $testRow->switchFlagSubtableIsLoaded();
     $this->assertFalse($testRow->isSubtableLoaded());
     $testRow->sumSubtable($subTable);
     $this->assertTrue(DataTable::isEqual($testRow->getSubtable(), $subTable));
 }
開發者ID:TensorWrenchOSS,項目名稱:piwik,代碼行數:11,代碼來源:RowTest.php


注:本文中的Piwik\DataTable::isEqual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。