diff --git a/tests/model/MongoStatementTest.php b/tests/model/MongoStatementTest.php index bef39ef..a85f626 100644 --- a/tests/model/MongoStatementTest.php +++ b/tests/model/MongoStatementTest.php @@ -207,7 +207,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase public function testFetch() { Config::set('PROFILER', true); - Config::set('PROFILER_DETAILS', true); + Config::set('PROFILER_DETAILS', false); $this->assertFalse($this->stmt->fetch()); $this->setDriverGetConnectionMethod()->setRequestForFetch(); @@ -216,6 +216,7 @@ class MongoStatementTest extends PHPUnit_Framework_TestCase $result = $this->stmt->fetch(); $this->assertEquals('prev', $result->next); $this->assertFalse($this->stmt->fetch()); + $this->assertContains('Queries not counted.', Profiler::getInstance()->getCli()); } /** diff --git a/tests/model/MySQLiStatementTest.php b/tests/model/MySQLiStatementTest.php index 22c13be..2a66c89 100644 --- a/tests/model/MySQLiStatementTest.php +++ b/tests/model/MySQLiStatementTest.php @@ -220,6 +220,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase */ public function testClose() { + Config::set('PROFILER', true); Config::set('PROFILER_DETAILS', false); $this->assertAttributeEquals(null, 'result', $this->stmt); $this->setDriverGetConnectionMethod(); @@ -227,6 +228,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase $this->assertAttributeNotEquals(null, 'result', $this->stmt); $this->stmt->close(); $this->assertAttributeEquals(null, 'result', $this->stmt); + $this->assertContains('Queries not counted.', Profiler::getInstance()->getCli()); } /** diff --git a/tests/util/profiler/ProfilerTest.php b/tests/util/profiler/ProfilerTest.php index c3d4a90..2f2022c 100644 --- a/tests/util/profiler/ProfilerTest.php +++ b/tests/util/profiler/ProfilerTest.php @@ -72,6 +72,7 @@ class ProfilerTest extends PHPUnit_Framework_TestCase public function testStartEndNoCommandProfiler() { Config::set('PROFILER', true); + Config::set('PROFILER_DETAILS', true); $profiler = Profiler::getInstance(); $profiler->start(); $result = $profiler->end('
'); @@ -90,6 +91,7 @@ class ProfilerTest extends PHPUnit_Framework_TestCase public function testStartEndWithCommandProfiler() { Config::set('PROFILER', true); + Config::set('PROFILER_DETAILS', true); $this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false); $profiler = Profiler::getInstance(); @@ -105,14 +107,146 @@ class ProfilerTest extends PHPUnit_Framework_TestCase /** * @runInSeparateProcess */ + public function testStartEndWithCommandProfilerWithNonDetails() + { + Config::set('PROFILER', true); + Config::set('PROFILER_DETAILS', false); + + $this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false); + $profiler = Profiler::getInstance(); + $profiler->start(); + $result = $profiler->end(''); + $this->assertNotEquals('', $result); + $this->assertContains('Queries not counted.', $result); + } + + /** + * @runInSeparateProcess + */ + public function testStartEndWithCommandProfilerWithNonDetailsButExistingQueries() + { + Config::set('PROFILER', true); + Config::set('PROFILER_DETAILS', false); + + $this->getMock('CommandProfiler', array('getType', 'getCommand', 'getElapsed'), array(), 'CommandProfilerMock', false); + $profiler = Profiler::getInstance(); + $cmdProfiler = $profiler->profilerCommand('command', 'type'); + $profiler->start(); + $result = $profiler->end(''); + $this->assertNotEquals('', $result); + $this->assertStringEndsNotWith(']