public function testGetTaskByDescriptionThrowsExceptionWhenTaskNotFound() { $task = new Task("Task day."); $this->workingDay->addTask($task); $this->setExpectedException('JGimeno\\TaskReporter\\Domain\\Exception\\DomainException'); $this->workingDay->getTaskByDescription(new TaskDescription("No task.")); }
public function testWorkingDayCanReturnAllTasks() { $task = new Task("Task day."); $this->workingDay->addTask($task); $tasks = $this->workingDay->getTasks(); $this->assertCount(1, $tasks); }
/** * @return WorkingDay */ private function createWorkingDayWithTwoTasks() { $workingDay = new WorkingDay(WorkingDayId::generate()); $normalTask = new Task("Take a bath."); $taskWithTicket = new Task("#1234# Take a pint."); $workingDay->addTask($normalTask); $workingDay->addTask($taskWithTicket); return $workingDay; }
public function createWorkingDayWithTwoTasks() { $workingDay = new WorkingDay(WorkingDayId::generate()); $task1 = new Task("Going to the toilet"); $task2 = new Task("Return from the toilet"); $workingDay->addTask($task1); $workingDay->addTask($task2); return $workingDay; }
public function testICanDeleteTaskFromTheWorkingDayFromCommand() { $workingDay = new WorkingDay(WorkingDayId::generate()); $workingDay->addTask(new Task("Task test")); $this->workingDayRepo->add($workingDay); $this->commandHandler->handle(new DeleteTask("Task test")); $this->assertCount(0, $workingDay->getTasks()); }
public function testICanAddATaskFromCommand() { $command = new AddTask("Task test"); $this->commandHandler->handle($command); $workingDayFromRepo = $this->workingDayRepo->getByDate(Carbon::now()); $expectedWorkingDay = new WorkingDay(WorkingDayId::generate()); $expectedWorkingDay->addTask(new Task("Task test")); $this->assertEquals($expectedWorkingDay->getDate(), $workingDayFromRepo->getDate()); }
public function handle(AddTask $command) { $task = new Task($command->getTask()); $workingDay = $this->workingDayRepo->getByDate(Carbon::now()); if (!$workingDay) { $workingDay = new WorkingDay($this->workingDayRepo->nextIdentity()); } $workingDay->addTask($task); $this->workingDayRepo->add($workingDay); }
public function testItWorksCorrectlyWhenYouHaveAWorkingDay() { $inMemoryRepo = new InMemoryWorkingDayRepository(); $workingDay = new WorkingDay($inMemoryRepo->nextIdentity()); $workingDay->addTask(new Task("Going to the toilet.")); $inMemoryRepo->add($workingDay); $this->mockMailProvider->expects($this->once())->method('sendReportOf')->with($workingDay); $sendReportHandler = new SendReportHandler($this->mockMailProvider, $inMemoryRepo); $sendReportHandler->handle(new SendReport()); }
public function testItReturnsTheRenderedTemplateUsingFile() { $workingDay = new WorkingDay(WorkingDayId::generate()); $taskWithTicket = new Task("#1234# Task with ticket."); $taskWithoutTicket = new Task("Task without ticket."); $workingDay->addTask($taskWithTicket); $workingDay->addTask($taskWithoutTicket); $templateRender = new DustMailTemplate(new Dust(), __DIR__ . "/files/testtemplate.dust", 'Daily Report #date# for Manolo'); $template = $templateRender->renderBody($workingDay); $expectedTemplate = <<<TEXT <h1>Today I did</h1> <li>(1234) Task with ticket.</li> <li>Task without ticket.</li> TEXT; $expectedSubject = 'Daily Report ' . date('Y-m-d') . ' for Manolo'; $this->assertEquals($expectedSubject, $templateRender->renderSubject($workingDay)); $this->assertEquals($expectedTemplate, $template); }
/** * @return WorkingDay */ private function getWorkingDayWithTask() { $workingDay = new WorkingDay(WorkingDayId::generate()); $workingDay->addTask(new Task("Task test.")); return $workingDay; }
/** * @return WorkingDay */ private function getWorkingDayWithTask() { $workingDay = new WorkingDay($this->repo->nextIdentity()); $workingDay->addTask(new Task('Going to the bathroom.')); return $workingDay; }
/** * @return WorkingDay */ private function getWorkingDayWithTask() { $workingDay = new WorkingDay(WorkingDayId::generate()); $workingDay->addTask(new Task('Going to the bathroom.')); return $workingDay; }