当前位置: 首页>>代码示例>>PHP>>正文


PHP Row::isEqual方法代码示例

本文整理汇总了PHP中Piwik\DataTable\Row::isEqual方法的典型用法代码示例。如果您正苦于以下问题:PHP Row::isEqual方法的具体用法?PHP Row::isEqual怎么用?PHP Row::isEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\DataTable\Row的用法示例。


在下文中一共展示了Row::isEqual方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testWhenRowsInRandomOrderButSortSpecifiedShouldComputeSummaryRowAfterSort

 public function testWhenRowsInRandomOrderButSortSpecifiedShouldComputeSummaryRowAfterSort()
 {
     $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 Truncate($table, 2, DataTable::LABEL_SUMMARY_ROW, $columnToSortBy = 'nb');
     $filter->filter($table);
     $this->assertEquals(3, $table->getRowsCount());
     $expectedRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
     $this->assertTrue(Row::isEqual($table->getLastRow(), $expectedRow));
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:14,代码来源:TruncateTest.php

示例2: isEqual

 /**
  * Returns true if both DataTable instances are exactly the same.
  *
  * DataTables are equal if they have the same number of rows, if
  * each row has a label that exists in the other table, and if each row
  * is equal to the row in the other table with the same label. The order
  * of rows is not important.
  *
  * @param \Piwik\DataTable $table1
  * @param \Piwik\DataTable $table2
  * @return bool
  */
 public static function isEqual(DataTable $table1, DataTable $table2)
 {
     $table1->rebuildIndex();
     $table2->rebuildIndex();
     if ($table1->getRowsCount() != $table2->getRowsCount()) {
         return false;
     }
     $rows1 = $table1->getRows();
     foreach ($rows1 as $row1) {
         $row2 = $table2->getRowFromLabel($row1->getColumn('label'));
         if ($row2 === false || !Row::isEqual($row1, $row2)) {
             return false;
         }
     }
     return true;
 }
开发者ID:piwik,项目名称:piwik,代码行数:28,代码来源:DataTable.php

示例3: testSumRow

 /**
  * Simple test of the DataTable_Row
  */
 public function testSumRow()
 {
     $columns = array('test_int' => 145, 'test_float' => 145.5, 'test_float3' => 1.5, 'test_stringint' => "145", "test" => 'string fake', 'integerArrayToSum' => array(1 => 1, 2 => 10.0, 3 => array(1 => 2, 2 => 3)));
     $metadata = array('logo' => 'piwik.png', 'super' => array('this column has an array value, amazing'));
     $arrayRow = array(Row::COLUMNS => $columns, Row::METADATA => $metadata, 'fake useless key' => 38959, '43905724897' => 'value');
     $row1 = new Row($arrayRow);
     $columns2 = array('test_int' => 5, 'test_float' => 4.5, 'test_float2' => 14.5, 'test_stringint' => "5", 925824 => 'toto', 'integerArrayToSum' => array(1 => 5, 2 => 5.5, 3 => array(2 => 4)));
     $finalRow = new Row(array(Row::COLUMNS => $columns2));
     $finalRow->sumRow($row1);
     $columnsWanted = array('test_int' => 150, 'test_float' => 150.0, 'test_float2' => 14.5, 'test_float3' => 1.5, 'test_stringint' => 150, 'test' => 'string fake', 'integerArrayToSum' => array(1 => 6, 2 => 15.5, 3 => array(1 => 2, 2 => 7)), 925824 => 'toto');
     // Also testing that metadata is copied over
     $rowWanted = new Row(array(Row::COLUMNS => $columnsWanted, Row::METADATA => $metadata));
     $this->assertTrue(Row::isEqual($rowWanted, $finalRow));
     // testing that, 'sumRow' does not result in extra unwanted attributes being serialized
     $expectedRow = 'a:3:{i:0;a:8:{s:8:"test_int";i:150;s:10:"test_float";d:150;s:11:"test_float2";d:14.5;s:14:"test_stringint";i:150;i:925824;s:4:"toto";s:17:"integerArrayToSum";a:3:{i:1;i:6;i:2;d:15.5;i:3;a:2:{i:2;i:7;i:1;i:2;}}s:11:"test_float3";d:1.5;s:4:"test";s:11:"string fake";}i:1;a:2:{s:4:"logo";s:9:"piwik.png";s:5:"super";a:1:{i:0;s:39:"this column has an array value, amazing";}}i:3;N;}';
     $this->assertEquals($expectedRow, serialize($finalRow->export()));
     // Testing sumRow with disabled metadata sum
     $rowWanted = new Row(array(Row::COLUMNS => $columnsWanted));
     // no metadata
     $finalRow = new Row(array(Row::COLUMNS => $columns2));
     $finalRow->sumRow($row1, $enableCopyMetadata = false);
     $this->assertTrue(Row::isEqual($rowWanted, $finalRow));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:26,代码来源:DataTableTest.php


注:本文中的Piwik\DataTable\Row::isEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。