예제 #1
0
 public function testLogging()
 {
     $project = new Xinc_Project();
     $name = 'test ' . rand(21213, 123213);
     $project->setName($name);
     $message = 'info ' . rand(3123123, 123123213);
     $project->info($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     $message = 'debug ' . rand(3123123, 123123213);
     $project->debug($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     $message = 'warn ' . rand(3123123, 123123213);
     $project->warn($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     $message = 'error ' . rand(3123123, 123123213);
     $project->error($message);
     $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message');
     Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_VERBOSE);
     $message = 'verbose ' . rand(3123123, 123123213);
     ob_start();
     $project->verbose($message);
     $contents = ob_get_clean();
     $lastMsg = Xinc_StreamLogger::getLastLogMessage();
     Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_DEBUG);
     $this->assertTrue(strpos($lastMsg, $message) !== false, 'Last message should contain message');
     //$this->assertEquals($lastMsg, $contents,
     //                 'Last message should contain message');
 }