Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function create(JobInterface $job)
 {
     $level = $this->registry->get($job->getType())->getLogLevel();
     if (false === $level) {
         return new NullLogger();
     } elseif (null === $level) {
         $level = $this->level;
     }
     $handlers = $this->handlerFactory->createHandlers($job, $level, $this->bubble);
     return new Logger($this->buildChannel($job), array_merge($handlers, $this->handlers));
 }
 /**
  * @param int     $level
  * @param boolean $bubble
  * @dataProvider provideLevels
  */
 public function testCreateHandlers($level, $bubble)
 {
     $job = new Job();
     $factory1 = $this->createMock(HandlerFactoryInterface::class);
     $handler1 = $this->createMock(HandlerInterface::class);
     $factory2 = $this->createMock(HandlerFactoryInterface::class);
     $handler2 = $this->createMock(HandlerInterface::class);
     $factory1->expects($this->once())->method('createHandler')->with($job, $level, $bubble)->willReturn($handler1);
     $factory2->expects($this->once())->method('createHandler')->with($job, $level, $bubble)->willReturn($handler2);
     $this->subject->register($factory1);
     $this->subject->register($factory2);
     $handlers = $this->subject->createHandlers($job, $level, $bubble);
     $this->assertContains($handler1, $handlers);
     $this->assertContains($handler2, $handlers);
 }