-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from dpb587/bugfix-disabled-DebugStack
Fix DebugStack->stopQuery to prevent unnecessary timings when disabled.
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Logging; | ||
|
||
require_once __DIR__ . '/../../TestInit.php'; | ||
|
||
class DebugStackTest extends \Doctrine\Tests\DbalTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->logger = new \Doctrine\DBAL\Logging\DebugStack(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
unset($this->logger); | ||
} | ||
|
||
public function testLoggedQuery() | ||
{ | ||
$this->logger->startQuery('SELECT column FROM table'); | ||
$this->assertEquals( | ||
array( | ||
1 => array( | ||
'sql' => 'SELECT column FROM table', | ||
'params' => null, | ||
'types' => null, | ||
'executionMS' => 0, | ||
), | ||
), | ||
$this->logger->queries | ||
); | ||
|
||
$this->logger->stopQuery(); | ||
$this->assertGreaterThan(0, $this->logger->queries[1]['executionMS']); | ||
} | ||
|
||
public function testLoggedQueryDisabled() | ||
{ | ||
$this->logger->enabled = false; | ||
$this->logger->startQuery('SELECT column FROM table'); | ||
$this->assertEquals(array(), $this->logger->queries); | ||
|
||
$this->logger->stopQuery(); | ||
$this->assertEquals(array(), $this->logger->queries); | ||
} | ||
} |