Esempio n. 1
0
 /**
  * @covers Itkg\Batch\Component\Console\Batch::report
  */
 public function testReport()
 {
     $script = "";
     $this->object = new Batch(array("MY_BATCH"));
     $this->object->getConfiguration()->addLogger(\Itkg\Log\Factory::getLogger(array(array('handler' => new EchoHandler()))), "test");
     $this->assertEquals($script, $this->object->report());
 }
Esempio n. 2
0
 public function testWrite()
 {
     $logger = \Itkg\Log\Factory::getLogger();
     $msg = 'A message';
     ob_start();
     $logger->addInfo($msg);
     ob_end_flush();
     $return = ob_get_contents();
     $this->assertEquals($msg . PHP_EOL, $return);
 }
Esempio n. 3
0
 /**
  * Test NullLogger
  */
 public function testNullLogger()
 {
     $config = array(array('handler' => new EchoHandler(LogLevel::CRITICAL)));
     \Itkg\Log::$config['LOGGER'] = 'Itkg\\Log\\NullLogger';
     $logger = \Itkg\Log\Factory::getLogger($config);
     ob_start();
     $logger->addInfo('A message');
     ob_end_flush();
     $content = ob_get_contents();
     $this->assertEmpty($content);
 }
Esempio n. 4
0
 /**
  * test default handler where no default handler is defined
  */
 public function testGetDefaultHandlerWithUnvalidConfig()
 {
     \Itkg\Log::$config['DEFAULT_HANDLER'] = '';
     try {
         $logger = \Itkg\Log\Factory::getLogger(array());
         $this->fail('An exception must be thrown because no valid handler is defined');
     } catch (\Exception $e) {
     }
 }
Esempio n. 5
0
 /**
  * Ajout d'un logger à la pile
  * 
  * @covers Itkg\Batch\Configuration::addLogger
  */
 public function testAddLogger()
 {
     $logger = \Itkg\Log\Factory::getLogger(array(array('handler' => new EchoHandler())));
     $nbLogger = sizeof($this->object->getLoggers());
     $this->object->addLogger($logger);
     $this->assertEquals($nbLogger + 1, sizeof($this->object->getLoggers()));
 }
Esempio n. 6
0
 /**
  * Formate la liste des loggers si ceux-ci sont sous forme de tableaux
  * et non d'objets
  */
 public function initLoggers()
 {
     foreach ($this->getLoggers() as $key => $handler) {
         $this->loggers[$key] = LogFactory::getLogger(array($handler));
     }
 }