diff --git a/lib/Cake/Test/TestCase/Database/ConnectionTest.php b/lib/Cake/Test/TestCase/Database/ConnectionTest.php index 345a22ba0c4..608626cb2dc 100644 --- a/lib/Cake/Test/TestCase/Database/ConnectionTest.php +++ b/lib/Cake/Test/TestCase/Database/ConnectionTest.php @@ -18,17 +18,17 @@ use Cake\Core\Configure; use Cake\Database\Connection; +use Cake\Model\ConnectionManager; use Cake\TestSuite\TestCase; /** * Tests Connection class - * - **/ + */ class ConnectionTest extends TestCase { public function setUp() { parent::setUp(); - $this->connection = new Connection(Configure::read('Datasource.test')); + $this->connection = ConnectionManager::getDataSource('test'); } public function tearDown() { @@ -673,8 +673,13 @@ public function testLogFunction() { * @return void */ public function testLogBeginRollbackTransaction() { + $connection = $this->getMock( + '\Cake\Database\Connection', + ['connect'], + [Configure::read('Datasource.test')] + ); $logger = $this->getMock('\Cake\Database\Log\QueryLogger'); - $this->connection->logger($logger); + $connection->logger($logger); $logger->expects($this->at(0))->method('log') ->with($this->logicalAnd( $this->isInstanceOf('\Cake\Database\Log\LoggedQuery'), @@ -685,10 +690,10 @@ public function testLogBeginRollbackTransaction() { $this->isInstanceOf('\Cake\Database\Log\LoggedQuery'), $this->attributeEqualTo('query', 'ROLLBACK') )); - $this->connection->logQueries(true); - $this->connection->begin(); - $this->connection->begin(); //This one will not be logged - $this->connection->rollback(); + $connection->logQueries(true); + $connection->begin(); + $connection->begin(); //This one will not be logged + $connection->rollback(); } /** @@ -698,15 +703,20 @@ public function testLogBeginRollbackTransaction() { */ public function testLogCommitTransaction() { $logger = $this->getMock('\Cake\Database\Log\QueryLogger'); - $this->connection->logger($logger); + $connection = $this->getMock( + '\Cake\Database\Connection', + ['connect'], + [Configure::read('Datasource.test')] + ); + $connection->logger($logger); $logger->expects($this->at(1))->method('log') ->with($this->logicalAnd( $this->isInstanceOf('\Cake\Database\Log\LoggedQuery'), $this->attributeEqualTo('query', 'COMMIT') )); - $this->connection->logQueries(true); - $this->connection->begin(); - $this->connection->commit(); + $connection->logQueries(true); + $connection->begin(); + $connection->commit(); } } diff --git a/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php b/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php index 1e0ec338168..8fe5c6fd16b 100644 --- a/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php +++ b/lib/Cake/Test/TestCase/Database/Driver/PostgresTest.php @@ -25,7 +25,6 @@ /** * Tests Postgres driver - * */ class PostgresTest extends \Cake\TestSuite\TestCase {