Example #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');
 }
 public function testEngineCannotValidate()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testEngineCannotValidate.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
         $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), 'cannot load engine') !== false, 'We should have a log message about the engine not being able to load');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     try {
         $engine = Xinc_Engine_Repository::getInstance()->getEngine('SunriseCannotValidate');
         $this->assertTrue(false, 'Should throw an exception');
     } catch (Xinc_Engine_Exception_NotFound $e) {
         $this->assertTrue(true, 'Right Exception caught');
     } catch (Exception $pe) {
         $this->assertTrue(false, 'Should catch a NotFound exception but caught: ' . get_class($e));
     }
 }
Example #3
0
 public function testLogVerbose()
 {
     $message = 'Test Debug: ' . rand(100, 99999999);
     $this->sharedFixture->setLogLevel(Xinc_Logger::LOG_LEVEL_VERBOSE);
     $this->sharedFixture->verbose($message);
     $lastMessage = Xinc_StreamLogger::getLogMessageFromEnd(0);
     $this->sharedFixture->setLogLevel(Xinc_Logger::LOG_LEVEL_DEBUG);
     $this->assertTrue(strpos($lastMessage, $message) !== false, 'Message should contain the last Test');
     //$this->assertTrue(strpos($contents, $message)!==false, 'Output Message should contain the last Test');
     $this->assertTrue(strpos($lastMessage, 'verbose') !== false, 'Message should contain the debug hint');
     //$this->assertEquals($contents, $lastMessage, 'Verbose output and written message should be the same');
     $this->sharedFixture->flush();
     $lastMessage = Xinc_StreamLogger::getLogMessageFromEnd(1);
     $this->assertTrue(strpos($lastMessage, 'priority="verbose"') !== false, 'Message should contain the last Test');
     $message = 'Test Debug Verbose: ' . rand(100, 99999999);
     $this->sharedFixture->verbose($message);
     $lastMessage2 = Xinc_StreamLogger::getLogMessageFromEnd(1);
     $this->assertTrue(strpos($lastMessage2, $message) === false, 'Message should not contain the last Test');
     $this->assertEquals($lastMessage, $lastMessage2, 'Since we are not verbose anymore the last message ' . 'should not have been logged');
 }