Пример #1
0
 public function testCreateTask()
 {
     $task = $this->prophesize(TaskInterface::class);
     $workload = 'Test 1';
     $taskBuilder = $this->prophesize(TaskBuilderInterface::class);
     $this->taskRepository->create(TestHandler::class, $workload)->willReturn($task->reveal());
     $this->factory->createTaskBuilder($task->reveal(), $this->taskScheduler)->willReturn($taskBuilder->reveal());
     $result = $this->taskScheduler->createTask(TestHandler::class, $workload);
     $this->assertEquals($taskBuilder->reveal(), $result);
 }
Пример #2
0
 /**
  * Create new task.
  *
  * @param string $workload
  * @param CronExpression $cronExpression
  * @param string $handlerClass
  *
  * @return TaskInterface
  */
 protected function createTask($workload, CronExpression $cronExpression = null, $handlerClass = TestHandler::class)
 {
     $task = $this->taskRepository->create($handlerClass, $workload);
     if ($cronExpression) {
         $task->setInterval($cronExpression, new \DateTime(), new \DateTime('+1 year'));
     }
     $this->taskRepository->save($task);
     return $task;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function createTask($handlerClass, $workload = null)
 {
     return $this->factory->createTaskBuilder($this->taskRepository->create($handlerClass, $workload), $this);
 }