/** * @covers Aclivo\Kpi\SumTotalizer::totalize */ public function testTotalizer() { $margin = 0.3; $actual = 0; $target = 0; $lowBand = 0; $highBand = 0; $datapoints = array(); for ($x = 1; $x <= 12; $x++) { $dp = new DataPoint(); $dp->setDate(DateTime::createFromFormat('Y-n-d', "2014-{$x}-01")); $actual += $x * 1000; $dp->setActual($x * 1000); $target += $x * 1000 * 1 + $margin; $dp->setTarget($x * 1000 * 1 + $margin); $dp->setMargin($margin); $lowBand += $dp->getLowBandTarget(); $highBand += $dp->getHighBandTarget(); $datapoints[] = $dp; } $totalizer = new SumTotalizer(); $total = $totalizer->totalize($datapoints); $this->assertEquals($actual, $total->getActual()); $this->assertEquals($target, $total->getTarget()); $this->assertEquals($lowBand, $total->getLowBandTarget()); $this->assertEquals($highBand, $total->getHighBandTarget()); }
/** * @covers Aclivo\Kpi\DataPoint::getLowBandTarget */ public function testGetLowBandTarget() { $target = 100; $margin = 0.1; $result = 90; $dp = new DataPoint(); $dp->setTarget($target); $dp->setMargin($margin); $this->assertEquals($result, $dp->getLowBandTarget()); }