DebugLogTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * DebugLog test class
  4. *
  5. * @author Christopher Han <xiphux@gmail.com>
  6. * @copyright Copyright (c) 2012 Christopher Han
  7. * @package GitPHP
  8. * @subpackage Test
  9. */
  10. class GitPHP_DebugLogTest extends PHPUnit_Framework_TestCase
  11. {
  12. protected $log;
  13. protected function setUp()
  14. {
  15. // $this->log = new GitPHP_DebugLog();
  16. }
  17. public function testLog()
  18. {
  19. /*
  20. $this->assertFalse($this->log->GetEnabled());
  21. $this->log->Log('Test log message');
  22. $this->log->ObjectChanged(null, GitPHP_Observer_Interface::LoggableChange, array('Test log message'));
  23. $this->assertCount(0, $this->log->GetEntries());
  24. $this->log->SetEnabled(true);
  25. $this->assertTrue($this->log->GetEnabled());
  26. $this->log->Log('Test log message');
  27. $this->log->ObjectChanged(null, GitPHP_Observer_Interface::LoggableChange, array('Test log message 2'));
  28. $data = $this->log->GetEntries();
  29. $this->assertCount(2, $data);
  30. $this->assertEquals('DEBUG: Test log message', $data[0]);
  31. $this->assertEquals('DEBUG: Test log message 2', $data[1]);
  32. $this->log->Clear();
  33. $this->assertCount(0, $this->log->GetEntries());
  34. $this->log->SetEnabled(false);
  35. $this->assertFalse($this->log->GetEnabled());
  36. */
  37. }
  38. public function testBenchmark()
  39. {
  40. /*
  41. $this->log->SetEnabled(true);
  42. $this->assertFalse($this->log->GetBenchmark());
  43. $this->log->SetBenchmark(true);
  44. $this->assertTrue($this->log->GetBenchmark());
  45. $this->log->Log('Test log message');
  46. $data = $this->log->GetEntries();
  47. $this->assertCount(3, $data);
  48. $this->assertRegExp('/^DEBUG: \[[0-9]+(\.[0-9]+)?\] \[[0-9]+ bytes\] Start$/', $data[0]);
  49. $this->assertRegExp('/^DEBUG: \[[0-9]+(\.[0-9]+)?\] \[[0-9]+(\.[0-9]+)?(E-[0-9]+)? sec since start\] \[[0-9]+(\.[0-9]+)?(E-[0-9]+)? sec since last\] \[[0-9]+ bytes\] \[[0-9]+ bytes since start\] \[[0-9]+ bytes since last\] Test log message$/', $data[1]);
  50. $this->assertRegExp('/^DEBUG: \[[0-9]+(\.[0-9]+)?\] \[[0-9]+(\.[0-9]+)?(E-[0-9]+)? sec since start\] \[[0-9]+(\.[0-9]+)?(E-[0-9]+)? sec since last\] \[[0-9]+ bytes\] \[[0-9]+ bytes since start\] \[[0-9]+ bytes since last\] End$/', $data[2]);
  51. $this->log->Clear();
  52. $this->log->SetBenchmark(false);
  53. $this->assertFalse($this->log->GetBenchmark());
  54. $this->log->SetEnabled(false);
  55. */
  56. }
  57. }