public function testSetters()
 {
     $aggregationMock = $this->getMock('IgraalOSL\\StatsTable\\Aggregation\\AggregationInterface');
     $values = array(3, 5);
     $column = new StatsColumnBuilder($values, 'Hits');
     $column->setHeaderName('Hits2');
     $this->assertEquals('Hits2', $column->getHeaderName());
     $this->assertNull($column->getAggregation());
     $column->setAggregation($aggregationMock);
     $this->assertEquals($aggregationMock, $column->getAggregation());
 }
示例#2
0
 /**
  * Append columns given a table
  *
  * @param array                  $table
  * @param string[]               $headers
  * @param string[]               $formats
  * @param AggregationInterface[] $aggregations
  * @param string[]               $columnNames
  * @param mixed[]                $defaultValues
  */
 public function appendTable($table, $headers, $formats, $aggregations, $columnNames = array(), $defaultValues = array(), $metaData = array())
 {
     $this->defaultValues = array_merge($this->defaultValues, $defaultValues);
     if (count($columnNames) === 0 && count($table) !== 0) {
         $columnNames = array_keys(reset($table));
     }
     if (count($columnNames) === 0 && count($headers) !== 0) {
         $columnNames = array_keys($headers);
     }
     foreach ($columnNames as $columnName) {
         $column = new StatsColumnBuilder($this->getAssocColumn($table, $columnName), $this->getParameter($headers, $columnName, $columnName), $this->getParameter($formats, $columnName), $this->getParameter($aggregations, $columnName), $this->getParameter($metaData, $columnName, array()));
         if (count($this->defaultValues)) {
             $column->insureIsFilled($this->indexes, $this->defaultValues[$columnName]);
         }
         $this->columns[$columnName] = $column;
     }
 }