Example #1
0
 public function before()
 {
     $this->calendar = Mockster::of(Calendar::class);
     $this->store = new EventStore();
     $this->uid = new FakeUidGenerator();
     $this->baseUrl = Url::fromString('http://example.com/ucdi');
     $this->givenNowIs('now');
     Mockster::stub($this->calendar->insertEvent(Arg::any(), Arg::any(), Arg::any(), Arg::any(), Arg::any()))->will()->call(function ($args) {
         return 'Event-' . $args['summary'];
     });
 }
Example #2
0
 public function handleScheduleBrick(ScheduleBrick $command)
 {
     if (!isset($this->goalOfTask[$command->getTask()])) {
         throw new \Exception("Task [{$command->getTask()}] does not exist.");
     }
     if ($command->getStart() < $this->now) {
         throw new \Exception('Cannot schedule brick in the past');
     }
     $brickId = $this->uid->generate('Brick');
     $events = [new BrickScheduled($brickId, $command->getTask(), $command->getDescription(), $command->getStart(), $command->getDuration())];
     if ($this->settings->calendarId) {
         $eventId = $this->calendar->insertEvent($this->settings->calendarId, $command->getDescription(), $command->getStart(), $command->getStart()->add($command->getDuration()), 'Show goal: ' . $this->base->appended('ShowGoalOfBrick')->withParameter('brick', $brickId) . "\n" . 'Mark as laid: ' . $this->base->appended('MarkBrickLaid')->withParameter('brick', $brickId));
         $events[] = new CalendarEventInserted($brickId, $this->settings->calendarId, $eventId);
     }
     return $events;
 }