From 17f2e99373cdfb302612b093cad3d1fe8053926c Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 28 Mar 2014 16:04:33 +0100 Subject: [PATCH] Using closeCursor in ConnectionTest, sqlite is very sad about open cursors --- tests/TestCase/Database/ConnectionTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/TestCase/Database/ConnectionTest.php b/tests/TestCase/Database/ConnectionTest.php index 1f73fbb3cb3..1ee18c2ef50 100644 --- a/tests/TestCase/Database/ConnectionTest.php +++ b/tests/TestCase/Database/ConnectionTest.php @@ -158,6 +158,7 @@ public function testExecuteWithArguments() { $statement = $this->connection->execute($sql, ['one' => 2, 'two' => 3], array('one' => 'integer', 'two' => 'integer')); $this->assertCount(1, $statement); $result = $statement->fetch('assoc'); + $statement->closeCursor(); $this->assertEquals(['total' => 6], $result); } @@ -176,6 +177,7 @@ public function testExecuteWithArgumentsAndTypes() { $params = [new \DateTime('2012-01-01 10:10:10'), '2000-01-01 10:10:10', 2.1]; $statement = $this->connection->execute($sql, $params, ['date', 'string', 'integer']); $result = $statement->fetch(); + $statement->closeCursor(); $this->assertEquals($result, array_filter($result)); } @@ -199,6 +201,7 @@ public function testExecuteWithNoParams() { $sql = 'SELECT 1'; $statement = $this->connection->execute($sql); $result = $statement->fetch(); + $statement->closeCursor(); $this->assertCount(1, $result); $this->assertEquals([1], $result); } @@ -275,8 +278,9 @@ public function testStatementReusing() { $this->_insertTwoRecords(); $total = $this->connection->execute('SELECT COUNT(*) AS total FROM things'); - $total = $total->fetch('assoc'); - $this->assertEquals(2, $total['total']); + $result = $total->fetch('assoc'); + $this->assertEquals(2, $result['total']); + $total->closeCursor(); $result = $this->connection->execute('SELECT title, body FROM things'); $row = $result->fetch('assoc'); @@ -284,6 +288,7 @@ public function testStatementReusing() { $this->assertEquals('a body', $row['body']); $row = $result->fetch('assoc'); + $result->closeCursor(); $this->assertEquals('another title', $row['title']); $this->assertEquals('another body', $row['body']); } @@ -300,6 +305,7 @@ public function testUpdateWithoutConditionsNorTypes() { $this->connection->update('things', ['title' => $title, 'body' => $body]); $result = $this->connection->execute('SELECT * FROM things WHERE title = ? AND body = ?', [$title, $body]); $this->assertCount(2, $result); + $result->closeCursor(); } /** @@ -314,6 +320,7 @@ public function testUpdateWithConditionsNoTypes() { $this->connection->update('things', ['title' => $title, 'body' => $body], ['id' => 2]); $result = $this->connection->execute('SELECT * FROM things WHERE title = ? AND body = ?', [$title, $body]); $this->assertCount(1, $result); + $result->closeCursor(); } /** @@ -328,6 +335,7 @@ public function testUpdateWithConditionsCombinedNoTypes() { $this->connection->update('things', ['title' => $title, 'body' => $body], ['id' => 2, 'body is not null']); $result = $this->connection->execute('SELECT * FROM things WHERE title = ? AND body = ?', [$title, $body]); $this->assertCount(1, $result); + $result->closeCursor(); } /** @@ -347,6 +355,7 @@ public function testUpdateWithTypes() { $this->assertEquals('2012-01-01', $row['body']); $row = $result->fetch('assoc'); $this->assertEquals('2012-01-01', $row['body']); + $result->closeCursor(); } /** @@ -364,6 +373,7 @@ public function testUpdateWithConditionsAndTypes() { $this->assertCount(1, $result); $row = $result->fetch('assoc'); $this->assertEquals('2012-01-01', $row['body']); + $result->closeCursor(); } /**