public function testGetTypeChoices() { $callable = array(new TestJob(), 'log'); $jobType = new JobType('service-id', 'JobType', $callable); $this->subject->register($jobType); $this->assertEquals(['JobType'], $this->subject->getTypeChoices()); }
/** * @param $withLogger * @dataProvider provideTrueFalse */ public function testInvokeHandlesLoggerAwareJobs($withLogger) { $serviceId = 'serviceId'; $type = 'callable-type'; $callable = new LoggerAwareJob(); $jobType = new JobType($serviceId, $type, array($callable, 'execute')); $logger = $this->createMock(LoggerInterface::class); $context = new Context($withLogger ? ['abc.logger' => $logger] : []); $job = new Job($type); $this->registry->register($jobType); $this->assertEquals('foobar', $this->subject->invoke($job, $context)); if ($withLogger) { $this->assertSame($logger, $callable->getLogger()); } else { $this->assertNull($callable->getLogger()); } }