|
@@ -906,13 +906,13 @@ class ConnectionTest extends TestCase
|
|
|
public function testLoggerDecorator()
|
|
public function testLoggerDecorator()
|
|
|
{
|
|
{
|
|
|
$logger = new QueryLogger;
|
|
$logger = new QueryLogger;
|
|
|
- $this->connection->logQueries(true);
|
|
|
|
|
|
|
+ $this->connection->enableQueryLogging(true);
|
|
|
$this->connection->setLogger($logger);
|
|
$this->connection->setLogger($logger);
|
|
|
$st = $this->connection->prepare('SELECT 1');
|
|
$st = $this->connection->prepare('SELECT 1');
|
|
|
$this->assertInstanceOf(LoggingStatement::class, $st);
|
|
$this->assertInstanceOf(LoggingStatement::class, $st);
|
|
|
$this->assertSame($logger, $st->getLogger());
|
|
$this->assertSame($logger, $st->getLogger());
|
|
|
|
|
|
|
|
- $this->connection->logQueries(false);
|
|
|
|
|
|
|
+ $this->connection->enableQueryLogging(false);
|
|
|
$st = $this->connection->prepare('SELECT 1');
|
|
$st = $this->connection->prepare('SELECT 1');
|
|
|
$this->assertNotInstanceOf('\Cake\Database\Log\LoggingStatement', $st);
|
|
$this->assertNotInstanceOf('\Cake\Database\Log\LoggingStatement', $st);
|
|
|
}
|
|
}
|
|
@@ -920,15 +920,32 @@ class ConnectionTest extends TestCase
|
|
|
/**
|
|
/**
|
|
|
* test logQueries method
|
|
* test logQueries method
|
|
|
*
|
|
*
|
|
|
|
|
+ * @deprecated
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
public function testLogQueries()
|
|
public function testLogQueries()
|
|
|
{
|
|
{
|
|
|
- $this->connection->logQueries(true);
|
|
|
|
|
- $this->assertTrue($this->connection->logQueries());
|
|
|
|
|
|
|
+ $this->deprecated(function () {
|
|
|
|
|
+ $this->connection->logQueries(true);
|
|
|
|
|
+ $this->assertTrue($this->connection->logQueries());
|
|
|
|
|
+
|
|
|
|
|
+ $this->connection->logQueries(false);
|
|
|
|
|
+ $this->assertFalse($this->connection->logQueries());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * test enableQueryLogging method
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testEnableQueryLogging()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->connection->enableQueryLogging(true);
|
|
|
|
|
+ $this->assertTrue($this->connection->isQueryLoggingEnabled());
|
|
|
|
|
|
|
|
- $this->connection->logQueries(false);
|
|
|
|
|
- $this->assertFalse($this->connection->logQueries());
|
|
|
|
|
|
|
+ $this->connection->enableQueryLogging(false);
|
|
|
|
|
+ $this->assertFalse($this->connection->isQueryLoggingEnabled());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -960,7 +977,7 @@ class ConnectionTest extends TestCase
|
|
|
->setMethods(['connect'])
|
|
->setMethods(['connect'])
|
|
|
->disableOriginalConstructor()
|
|
->disableOriginalConstructor()
|
|
|
->getMock();
|
|
->getMock();
|
|
|
- $connection->logQueries(true);
|
|
|
|
|
|
|
+ $connection->enableQueryLogging(true);
|
|
|
|
|
|
|
|
$driver = $this->getMockFormDriver();
|
|
$driver = $this->getMockFormDriver();
|
|
|
$connection->setDriver($driver);
|
|
$connection->setDriver($driver);
|
|
@@ -1004,7 +1021,7 @@ class ConnectionTest extends TestCase
|
|
|
$this->isInstanceOf('\Cake\Database\Log\LoggedQuery'),
|
|
$this->isInstanceOf('\Cake\Database\Log\LoggedQuery'),
|
|
|
$this->attributeEqualTo('query', 'COMMIT')
|
|
$this->attributeEqualTo('query', 'COMMIT')
|
|
|
));
|
|
));
|
|
|
- $connection->logQueries(true);
|
|
|
|
|
|
|
+ $connection->enableQueryLogging(true);
|
|
|
$connection->begin();
|
|
$connection->begin();
|
|
|
$connection->commit();
|
|
$connection->commit();
|
|
|
}
|
|
}
|