/**
  * Test simple case of getCardsMovedFromTodoToDone Method.
  */
 public function testGetCardsMoved()
 {
     $trelloClient = $this->getTrelloClientMock();
     $todoLists = [$this->getListMock('1')];
     $wipLists = [$this->getListMock('2')];
     $doneLists = [$this->getListMock('3')];
     $actionManager = new ActionManager($trelloClient);
     $cards = $actionManager->getCardsMovedFromTodoToDone($todoLists, $wipLists, $doneLists);
     $this->assertEquals($this->getCardsMovedFromTodoToDoneProvider('3'), $cards);
 }
 /**
  * Test done story points.
  */
 public function testGetDoneStoryPoints()
 {
     $trelloClient = $this->getTrelloClientMock();
     $actionManager = new ActionManager($trelloClient);
     $storyPointManager = new StoryPointManager($trelloClient, $actionManager);
     $todoLists = [$this->getListMock('1')];
     $wipLists = [$this->getListMock('2')];
     $doneLists = [$this->getListMock('3')];
     $sprint = $this->getSprintMock();
     $doneSP = $storyPointManager->getDoneStoryPoints($todoLists, $wipLists, $doneLists, $sprint);
     $doneCards = $actionManager->getCardsMovedFromTodoToDone($todoLists, $wipLists, $doneLists);
     $sprintDays = $sprint->getSprintDays();
     $sp = [];
     foreach ($sprintDays as $day) {
         $countSP = 0;
         if ($day instanceof \DateTime && $day->getTimestamp() > $sprint->getNextDayInSprint()->getTimestamp()) {
             break;
         }
         if ($day instanceof \DateTime && ($day->format('N') == 6 || $day->format('N') == 7)) {
             continue;
         }
         foreach ($doneCards as $card) {
             $actionDate = new \DateTime($card['date']);
             if ($actionDate->getTimestamp() > $sprint->getStart()->getTimestamp() && $actionDate->getTimestamp() < $day->getTimestamp()) {
                 $countSP += $storyPointManager->parseStoryPoints($card['card']);
             }
         }
         $sp[] = ['date' => $day, 'count' => $countSP];
     }
     $this->assertEquals($sp, $doneSP);
 }
 /**
  * Return an array of done story points per day.
  *
  * @param array  $todoLists
  * @param array  $wipLists
  * @param array  $doneLists
  * @param Sprint $sprint
  *
  * @return array|null
  */
 public function getDoneStoryPoints(array $todoLists, array $wipLists, array $doneLists, Sprint $sprint)
 {
     $doneCards = $this->actionManager->getCardsMovedFromTodoToDone($todoLists, $wipLists, $doneLists);
     $sprintDays = $sprint->getSprintDays();
     $sp = [];
     if (!$sprintDays instanceof \DatePeriod) {
         return;
     }
     foreach ($sprintDays as $day) {
         $countSP = 0;
         if ($day instanceof \DateTime && $day->getTimestamp() > $sprint->getNextDayInSprint()->getTimestamp()) {
             break;
         }
         if ($this->isWeekend($day)) {
             continue;
         }
         foreach ($doneCards as $card) {
             $actionDate = new \DateTime($card['date']);
             if ($actionDate->getTimestamp() > $sprint->getStart()->getTimestamp() && $actionDate->getTimestamp() < $day->getTimestamp()) {
                 $countSP += $this->parseStoryPoints($card['card']);
             }
         }
         $sp[] = ['date' => $day, 'count' => $countSP];
     }
     return $sp;
 }