public function testAddDataFieldWithAggregationType() { $type = AggregationType::MAX; $pivot = new PivotDescription($this->dataTable); $pivot->addDataField('expense', $type); $expected = array('expense'); $actual = $pivot->getDataFields(); $this->assertEquals($expected, $actual); $expected = $type; $actual = $pivot->getAggregationType('expense'); $this->assertNotNull($actual); $this->assertEquals($expected, $actual->getCode()); }
public function testAggregateCount() { $pivotDescription = new PivotDescription($this->dataTable, array('country')); $pivotDescription->addDataField('income', AggregationType::COUNT); $pivotAction = new PivotAction($pivotDescription); $data =& $pivotAction->execute(); $this->assertSame(2, $data->getNumberOfColumns()); $this->assertSame(3, $data->getNumberOfRows()); $col1 = $data->getColumnDescription(1); $this->assertSame('count US Income', $col1->getLabel()); $this->assertSame(3, $data->getRow(0)->getCell(1)->getValue()->getRawValue(), "Expect count(income) = 3 for US on day 1"); $this->assertSame(2, $data->getRow(1)->getCell(1)->getValue()->getRawValue(), "Expect count(income) = 2 for US on day 2"); $this->assertSame(2, $data->getRow(2)->getCell(1)->getValue()->getRawValue(), "Expect count(income) = 2 for US on day 3"); }