Example #1
0
 public function testGetJobLogger()
 {
     $job = new Job();
     $logger = new NullLogger();
     $this->loggerFactory->expects($this->once())->method('create')->with($job)->willReturn($logger);
     $this->assertSame($logger, $this->subject->getJobLogger($job));
 }
Example #2
0
 /**
  * @param ExecutionEvent $event
  * @return void
  */
 public function onPreExecute(ExecutionEvent $event)
 {
     $event->getContext()->set('abc.manager', $this->manager);
     $this->logger->debug('Added runtime parameter "manager" to context', ['abc.manager' => $this->manager]);
     $logger = $this->factory->create($event->getJob());
     $event->getContext()->set('abc.logger', $logger);
     $this->logger->debug('Added runtime parameter "logger" to context', ['abc.logger' => $logger]);
 }
 public function testOnPreExecuteRegistersLogger()
 {
     $job = new Job('JobTicket');
     $context = new Context();
     $logger = new NullLogger();
     $event = new ExecutionEvent($job, $context);
     $this->factory->expects($this->once())->method('create')->with($job)->willReturn($logger);
     $this->subject->onPreExecute($event);
     $this->assertTrue($context->has('abc.logger'));
     $this->assertSame($logger, $context->get('abc.logger'));
 }
Example #4
0
 /**
  * @param JobInterface $job
  * @return LoggerInterface
  */
 private function getJobLogger(JobInterface $job)
 {
     if (!isset($this->jobLogger[0]) || $job !== $this->jobLogger[0]) {
         $this->jobLogger[0] = $job;
         $this->jobLogger[1] = $this->loggerFactory->create($job);
     }
     return $this->jobLogger[1];
 }
Example #5
0
 public function testUpdate()
 {
     $job = new Job();
     $job->setTicket('JobTicket');
     $existingJob = new Job();
     $this->jobManager->expects($this->once())->method('findByTicket')->with($job->getTicket())->willReturn($existingJob);
     $this->helper->expects($this->once())->method('copyJob')->with($job, $existingJob)->willReturn($existingJob);
     $this->jobManager->expects($this->once())->method('save')->with($existingJob);
     $this->loggerFactory->expects($this->once())->method('create')->with($existingJob)->willReturn(new NullLogger());
     $this->subject->update($job);
 }
Example #6
0
 /**
  * @param EntityJobInterface $job
  * @return LoggerInterface
  */
 public function getJobLogger(EntityJobInterface $job)
 {
     return $this->loggerFactory->create($job);
 }