protected function addJobs() { foreach ($this->configuration->getJobs() as $jobArray) { $job = new ShellJob(); $job->setCommand($this->assembleShellJobString($jobArray['command'])); $job->setSchedule(new CrontabSchedule($jobArray['schedule'])); $this->getResolver()->addJob($job); } }
public function testGetRunningJobs() { $executor = new Executor(); $jobs = []; foreach ($this->configuration->getJobs() as $jobArray) { $jobMock = $this->getMock(ShellJob::class, ['isRunning']); $jobMock->setCommand($this->assembleShellJobString($jobArray['command'])); $jobMock->setSchedule(new CrontabSchedule($jobArray['schedule'])); $jobMock->expects($this->any())->method('isRunning')->will($this->returnValue(true)); $jobs[] = $jobMock; } $executor->setJobs($jobs); $this->assertEquals($jobs, $executor->getRunningJobs()); }
public function testRun() { $jobs = []; foreach ($this->configuration->getJobs() as $jobArray) { $job = new ShellJob(); $job->setCommand($this->assembleShellJobString($jobArray['command'])); $job->setSchedule(new CrontabSchedule($jobArray['schedule'])); $jobs[] = $job; } $cronMock = $this->getMock(Cron::class); $cronMock->expects($this->once())->method('run')->will($this->returnValue(null)); $service = new CronService($this->configuration); $service->setCron($cronMock); $service->run(); $serviceResolver = \PHPUnit_Framework_Assert::readAttribute($service, 'resolver'); $resolverJobs = \PHPUnit_Framework_Assert::readAttribute($serviceResolver, 'jobs'); $this->assertEquals($jobs, $resolverJobs); }
public function testSetAndHasJobs() { $configuration = new Configuration(); $configuration->setJobs($this->configuration->getJobs()); $this->assertTrue($configuration->hasJobs()); }