/** * Create and register all configured loggers. * * @param \phpbu\App\Configuration $configuration */ protected function setupLoggers(Configuration $configuration) { foreach ($configuration->getLoggers() as $log) { // this is a already fully setup Listener so just add it if (is_a($log, '\\phpbu\\App\\Listener')) { $logger = $log; } else { // this is a configuration blueprint for a logger, so create and add it /** @var \phpbu\App\Configuration\Logger $log */ /** @var \phpbu\App\Listener $logger */ $logger = $this->factory->createLogger($log->type, $log->options); } $this->result->addListener($logger); } }
/** * Tests Factory::createLogger * * @expectedException \phpbu\App\Exception */ public function testCreateLoggerThatIsLoggerButNoListener() { Factory::register('logger', 'nothing', '\\phpbu\\App\\phpbuAppFactoryTestLoggerButNoListener', true); $factory = new Factory(); $factory->createLogger('nothing'); $this->assertFalse(true, 'Exception should be thrown'); }