DebugStackTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Doctrine\Tests\DBAL\Logging;
  3. require_once __DIR__ . '/../../TestInit.php';
  4. class DebugStackTest extends \Doctrine\Tests\DbalTestCase
  5. {
  6. public function setUp()
  7. {
  8. $this->logger = new \Doctrine\DBAL\Logging\DebugStack();
  9. }
  10. public function tearDown()
  11. {
  12. unset($this->logger);
  13. }
  14. public function testLoggedQuery()
  15. {
  16. $this->logger->startQuery('SELECT column FROM table');
  17. $this->assertEquals(
  18. array(
  19. 1 => array(
  20. 'sql' => 'SELECT column FROM table',
  21. 'params' => null,
  22. 'types' => null,
  23. 'executionMS' => 0,
  24. ),
  25. ),
  26. $this->logger->queries
  27. );
  28. $this->logger->stopQuery();
  29. $this->assertGreaterThan(0, $this->logger->queries[1]['executionMS']);
  30. }
  31. public function testLoggedQueryDisabled()
  32. {
  33. $this->logger->enabled = false;
  34. $this->logger->startQuery('SELECT column FROM table');
  35. $this->assertEquals(array(), $this->logger->queries);
  36. $this->logger->stopQuery();
  37. $this->assertEquals(array(), $this->logger->queries);
  38. }
  39. }