public function testValidateWithType() { $job = new Job(); $job->setType('foobar'); $job->setParameters(['JobParameters']); $validator = $this->createMock(ValidatorInterface::class); $contextualValidator = $this->createMock(ContextualValidatorInterface::class); $this->context->expects($this->once())->method('getValidator')->willReturn($validator); $validator->expects($this->once())->method('inContext')->with($this->context)->willReturn($contextualValidator); $contextualValidator->expects($this->once())->method('atPath')->with('parameters')->willReturn($contextualValidator); $contextualValidator->expects($this->once())->method('validate')->with(['JobParameters'], new Parameters(['type' => $job->getType()])); $this->subject->validate($job, new JobConstraint()); }
public function testCreatesLoggerWithAddedHandlers() { $job = new Job(); $job->setType('JobType'); $handler = $this->createMock(HandlerInterface::class); $extraHandler = $this->createMock(HandlerInterface::class); $factory = $this->getMockBuilder(BaseHandlerFactory::class)->disableOriginalConstructor()->getMock(); $jobType = $this->createMock(JobTypeInterface::class); $this->handlerFactory->register($factory); $jobType->expects($this->any())->method('getLogLevel')->willReturn(Logger::CRITICAL); $this->registry->expects($this->once())->method('get')->with($job->getType())->willReturn($jobType); $factory->expects($this->once())->method('createHandler')->willReturn($handler); $this->subject->addHandler($extraHandler); $logger = $this->subject->create($job); $this->assertContains($handler, $logger->getHandlers()); $this->assertContains($extraHandler, $logger->getHandlers()); }