sumRowMetadata() публичный Метод

Sums the metadata in $rowToSum with the metadata in $this row.
public sumRowMetadata ( Row $rowToSum, array $aggregationOperations = [] )
$rowToSum Row
$aggregationOperations array
Пример #1
0
 public function test_sumRowMetadata_uniquearraymergeShouldUseArrayFromThisRow_IfNoMetadataForOtherRowSpecified()
 {
     $row = $this->getTestRowWithNoSubDataTable();
     $arrayValue = array(array('test' => 3, 'value' => 3), array('test' => 2, 'value' => 2));
     $this->row->setMetadata('my_array', $arrayValue);
     $aggregations = array('my_array' => 'uniquearraymerge');
     $this->row->sumRowMetadata($row, $aggregations);
     $this->assertSame(array('my_array' => $arrayValue), $this->row->getMetadata());
 }
Пример #2
0
 public function testSumRowMetadata_CustomAggregationOperation()
 {
     $metadata1 = array('mytest' => 'value1');
     $metadata2 = array('mytest' => 'value2');
     $self = $this;
     $row1 = new Row(array(Row::COLUMNS => array('test_int' => 145), Row::METADATA => $metadata1));
     $finalRow = new Row(array(Row::COLUMNS => array('test_int' => 5), Row::METADATA => $metadata2));
     $finalRow->sumRowMetadata($row1, array('mytest' => function ($thisValue, $otherValue, $thisRow, $otherRow) use($self, $row1, $finalRow) {
         $self->assertEquals('value2', $thisValue);
         $self->assertEquals('value1', $otherValue);
         $self->assertSame($thisRow, $finalRow);
         $self->assertSame($otherRow, $row1);
         if (!is_array($thisValue)) {
             $thisValue = array($thisValue);
         }
         $thisValue[] = $otherValue;
         return $thisValue;
     }));
     $this->assertEquals(array('value2', 'value1'), $finalRow->getMetadata('mytest'));
 }