/** * @Given I have the following tasks: */ public function iHaveTheFollowingTasks(TableNode $table) { $this->repository = $this->getContainer()->get('doctrine')->getManager()->getRepository('AppBundle:Task'); $this->manager = $this->getContainer()->get('doctrine')->getManager(); $allTasks = $this->repository->findAllAsArray(); $tableTasks = $table->getHash(); foreach ($allTasks as $k => $task) { if ($tableTasks[$k] != $task) { var_dump($task); var_dump($tableTasks[$k]); throw new Exception('Tasks not even'); } } }
/** * @param int $listId * @param int $taskId * @return Task */ public function resolveTask($listId, $taskId) { $task = $this->taskRepository->getTask($listId, $taskId); $task->setStatus(Task::STATUS_DONE); $this->objectManager->persist($task); $this->objectManager->flush(); return $task; }
public function testResolveTask() { $listId = 1; $taskId = 1; $task = new Task(); $this->taskRepository->expects($this->once())->method('getTask')->with($listId, $taskId)->willReturn($task); $this->em->expects($this->once())->method('flush'); $task = $this->todoService->resolveTask($listId, $taskId); $this->assertEquals(Task::STATUS_DONE, $task->getStatus()); }