/**
  * Update a new Task.
  *
  * @param TaskEntity $entity
  *
  * @return TaskEntity
  */
 public function update(TaskEntity $entity, $oldElements)
 {
     foreach ($this->tasks as $key => $value) {
         if ($entity->getId() == $value->getId()) {
             $this->tasks[$key] = $entity;
             return $entity;
         }
     }
     return null;
 }
예제 #2
0
 protected function entityToGetTaskResponse(TaskEntity $entity)
 {
     $dto = new GetTaskResponse();
     $dto->id = $entity->getId();
     $dto->title = $entity->getTitle();
     $dto->startDate = $entity->getStartDate();
     $dto->endDate = $entity->getEndDate();
     $dto->status = $entity->getStatus();
     $dto->elements = array_values(array_map(function ($element) {
         return $element->getElement();
     }, $entity->getElements()->toArray()));
     $user = $entity->getAssignedUser();
     $dto->memberEmail = $user != null ? $user->getEmail() : "";
     return $dto;
 }
 protected function assertGetTaskResponse($decoded, TaskEntity $orgTask)
 {
     $this->assertTrue(isset($decoded['id']));
     $this->assertTrue(isset($decoded['title']));
     $this->assertTrue(isset($decoded['memberEmail']));
     $this->assertTrue(isset($decoded['startDate']));
     $this->assertTrue(isset($decoded['endDate']));
     $this->assertTrue(isset($decoded['status']));
     $this->assertTrue(isset($decoded['elements']));
     $this->assertEquals($orgTask->getId(), $decoded['id']);
     $this->assertEquals($orgTask->getTitle(), $decoded['title']);
     $this->assertEquals($orgTask->getAssignedUser()->getEmail(), $decoded['memberEmail']);
     $this->assertEquals($orgTask->getStartDate(), \DateTime::createFromFormat("Y-m-d", $decoded['startDate']));
     $this->assertEquals($orgTask->getEndDate(), \DateTime::createFromFormat("Y-m-d", $decoded['endDate']));
     $this->assertEquals($orgTask->getStatus(), $decoded['status']);
     $this->assertEquals(count($decoded['elements']), count($orgTask->getElements()));
     foreach ($decoded['elements'] as $k => $v) {
         $this->assertEquals($v, $orgTask->getElements()[$k]->getElement());
     }
 }