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());
 }
 /**
  * @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 handle(AddTask $command)
 {
     $task = new Task($command->getTask());
     $workingDay = $this->workingDayRepo->getByDate(Carbon::now());
     if (!$workingDay) {
         $workingDay = new WorkingDay(WorkingDayId::generate());
     }
     $workingDay->addTask($task);
     $this->workingDayRepo->add($workingDay);
 }
 /**
  * @expectedException JGimeno\TaskReporter\Infrastructure\Exception\MailProviderException
  * @expectedExceptionMessage Error with mail provider:
  */
 public function testItFailsWhenThereIsAProblemWithPhpMailerClient()
 {
     $mockPHPMailer = $this->getMockBuilder(PHPMailer::class)->getMock();
     $mockPHPMailer->expects($this->once())->method('send')->willThrowException(new Exception());
     $this->mockTemplate->expects($this->once())->method('renderSubject');
     $this->mockTemplate->expects($this->once())->method('renderBody');
     $mailOptions = new MailOptions('hola', 'este', new Password('es'), "", "");
     $phpmailer = new PhpMailerMailProvider($mockPHPMailer, $mailOptions, $this->mockTemplate);
     $phpmailer->sendReportOf(new WorkingDay(WorkingDayId::generate()));
 }
    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 WorkingDayId
  */
 public function nextIdentity()
 {
     return WorkingDayId::generate();
 }
 public function testInstanceOf()
 {
     $workingDayId = WorkingDayId::generate();
     $this->assertInstanceOf('JGimeno\\TaskReporter\\Domain\\Value\\WorkingDayId', $workingDayId);
 }
 protected function setUp()
 {
     parent::setUp();
     $this->workingDay = new WorkingDay(WorkingDayId::generate());
 }
 /**
  * @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(WorkingDayId::generate());
     $workingDay->addTask(new Task('Going to the bathroom.'));
     return $workingDay;
 }