You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.3 KiB

  1. <?php
  2. /**
  3. * PhpUnderControl_PhalApiLoggerExplorer_Test
  4. *
  5. * 针对 ../test_file_for_loader.php PhalApi_Logger_Explorer 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20150205
  8. */
  9. require_once dirname(__FILE__) . '/../test_env.php';
  10. if (!class_exists('PhalApi_Logger_Explorer')) {
  11. require dirname(__FILE__) . '/../test_file_for_loader.php';
  12. }
  13. class PhpUnderControl_PhalApiLoggerExplorer_Test extends PHPUnit_Framework_TestCase
  14. {
  15. public $phalApiLoggerExplorer;
  16. protected function setUp()
  17. {
  18. parent::setUp();
  19. $this->phalApiLoggerExplorer = new PhalApi_Logger_Explorer(
  20. PhalApi_Logger::LOG_LEVEL_DEBUG | PhalApi_Logger::LOG_LEVEL_INFO | PhalApi_Logger::LOG_LEVEL_ERROR);
  21. }
  22. protected function tearDown()
  23. {
  24. }
  25. /**
  26. * @group testLog
  27. */
  28. public function testLog()
  29. {
  30. $type = 'test';
  31. $msg = 'this is a test msg';
  32. $data = array('from' => 'testLog');
  33. $this->phalApiLoggerExplorer->log($type, $msg, $data);
  34. $this->expectOutputRegex('/TEST|this is a test msg|{"from":"testLog"}/');
  35. }
  36. public function testLogButNoShow()
  37. {
  38. $logger = new PhalApi_Logger_Explorer(0);
  39. $logger->info('no info');
  40. $logger->debug('no debug');
  41. $logger->error('no error');
  42. $this->expectOutputString('');
  43. }
  44. }