Beispiel #1
0
 public function testAddTask()
 {
     $listId = 1;
     $list = new TodoList();
     $this->todoListRepository->expects($this->once())->method('getList')->with($listId)->willReturn($list);
     $this->em->expects($this->atLeastOnce())->method('persist');
     $this->em->expects($this->once())->method('flush');
     $task = $this->todoService->addTask($listId, "test");
     $this->assertEquals("test", $task->getText());
 }
Beispiel #2
0
 /**
  * @param int $listId
  * @param string $text
  * @return Task
  */
 public function addTask($listId, $text)
 {
     $task = new Task();
     $task->setText($text);
     $todoList = $this->todoListRepository->getList($listId);
     $todoList->addTask($task);
     $task->setTodoList($todoList);
     $this->objectManager->persist($task);
     $this->objectManager->persist($todoList);
     $this->objectManager->flush();
     return $task;
 }