Example #1
0
 public function testAddSubscriber()
 {
     $taskProviderA = $this->getMock(TaskProviderInterface::class);
     $taskA = $this->getMock(TaskInterface::class);
     $taskSubscriberB = $this->getMock(TaskProviderInterface::class);
     $taskB = $this->getMock(TaskInterface::class);
     $taskProviderA->expects($this->once())->method('getTasks')->willReturn([$taskA]);
     $taskSubscriberB->expects($this->once())->method('getTasks')->willReturn([$taskB]);
     $scheduler = new Scheduler();
     $scheduler->addProvider($taskProviderA);
     $scheduler->addProvider($taskSubscriberB);
     $tasks = $scheduler->getTasks();
     $this->assertCount(2, $tasks);
 }
Example #2
0
 public function testTaskRunningInSeparateProcess()
 {
     $scheduler = new Scheduler();
     $subscriber = new SimpleProvider();
     $subscriber->addTask(new BadTask());
     $subscriber->addTask(new Task($firstFile = $this->tmpDir . '/1'));
     $scheduler->addProvider($subscriber);
     $scheduler->run();
     // Запуск происходит асинхронно, ждём
     sleep(1);
     $this->assertFileExists($firstFile);
 }