コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 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());
 }