public function handle(AssignCategoryToTask $command) { $task = $command->getTask(); $category = $command->getCategory(); $task->addCategory($category); $this->em->persist($task); $this->em->flush(); }
function it_assigns_category_to_task(AssignCategoryToTask $command, Task $task, Category $category, $em) { $command->getCategory()->willReturn($category); $command->getTask()->willReturn($task); $task->addCategory($category)->shouldBeCalled($category); $em->persist($task)->shouldBeCalled(); $em->flush()->shouldBeCalled(); $this->handle($command); }