예제 #1
0
 /**
  * @covers Aclivo\Kpi\UpDirector::getDirection
  * @covers Aclivo\Kpi\UpDirector::goodDirection
  * @covers Aclivo\Kpi\UpDirector::betterDirection
  * @covers Aclivo\Kpi\UpDirector::badDirection
  * @covers Aclivo\Kpi\UpDirector::worseDirection
  */
 public function testGetDirection()
 {
     $datapoint = new DataPoint();
     $datapoint->setActual(100);
     $datapoint->setTarget(100);
     $datapoint->setMargin(0.2);
     $director = new UpDirector();
     $this->assertEquals(Directions::GOOD, $director->getDirection($datapoint));
     $datapoint->setActual(105);
     $this->assertEquals(Directions::GOOD, $director->getDirection($datapoint));
     $datapoint->setActual(121);
     $this->assertEquals(Directions::BETTER, $director->getDirection($datapoint));
     $datapoint->setActual(98);
     $this->assertEquals(Directions::BAD, $director->getDirection($datapoint));
     $datapoint->setActual(70);
     $this->assertEquals(Directions::WORSE, $director->getDirection($datapoint));
 }
예제 #2
0
파일: ViewTest.php 프로젝트: aclivo/kpi
 /**
  * @covers Aclivo\Kpi\View::setTotalizer
  * @covers Aclivo\Kpi\View::getTotal
  */
 public function testSetTotalizer()
 {
     $actual = 0;
     $points = array();
     for ($x = 1; $x <= 5; $x++) {
         $dp = new DataPoint();
         $dp->setActual($x * 100);
         $actual += $x * 100;
         $dp->setTarget($x * 100);
         $dp->setMargin(0.1);
         $points[] = $dp;
     }
     $view = new View();
     $view->setDataPoints($points);
     $totalizer = new SumTotalizer();
     $view->setTotalizer($totalizer);
     $this->assertEquals($actual, $view->getTotal()->getActual());
 }