aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-07-16 10:38:12 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-07-21 15:25:47 +0200
commit32cb30cb8400032d334873a3205e68bea7f909f5 (patch)
treeb7079afc79db5f30d1e2b9dc3ab9376666e86ce1 /tests
parent577a7c92e18d598389cbce97dcf80ebe00811a6b (diff)
downloadnextcloud-server-32cb30cb8400032d334873a3205e68bea7f909f5.tar.gz
nextcloud-server-32cb30cb8400032d334873a3205e68bea7f909f5.zip
Correctly count the number of items (rowCount is Update/Insert/Delete only)
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db/querybuilder/querybuildertest.php35
1 files changed, 22 insertions, 13 deletions
diff --git a/tests/lib/db/querybuilder/querybuildertest.php b/tests/lib/db/querybuilder/querybuildertest.php
index 4ee44bb8dd7..8be0c5d17e7 100644
--- a/tests/lib/db/querybuilder/querybuildertest.php
+++ b/tests/lib/db/querybuilder/querybuildertest.php
@@ -25,17 +25,20 @@ use Doctrine\DBAL\Query\Expression\CompositeExpression;
use OC\DB\QueryBuilder\Literal;
use OC\DB\QueryBuilder\Parameter;
use OC\DB\QueryBuilder\QueryBuilder;
+use OCP\IDBConnection;
class QueryBuilderTest extends \Test\TestCase {
/** @var QueryBuilder */
protected $queryBuilder;
+ /** @var IDBConnection */
+ protected $connection;
+
protected function setUp() {
parent::setUp();
- $connection = \OC::$server->getDatabaseConnection();
-
- $this->queryBuilder = new QueryBuilder($connection);
+ $this->connection = \OC::$server->getDatabaseConnection();
+ $this->queryBuilder = new QueryBuilder($this->connection);
}
public function dataFirstResult() {
@@ -54,18 +57,18 @@ class QueryBuilderTest extends \Test\TestCase {
* @param array $expectedSet
*/
public function testFirstResult($firstResult, $expectedSet) {
- $eB = $this->queryBuilder->expr();
+ $qB = $this->connection->getQueryBuilder();
+ $eB = $qB->expr();
for ($i = 1; $i < 10; $i++) {
- $this->queryBuilder->insert('*PREFIX*appconfig')
+ $qB->insert('*PREFIX*appconfig')
->values([
'appid' => $eB->literal('testFirstResult'),
'configkey' => $eB->literal('testing' . $i),
'configvalue' => $eB->literal(100 - $i),
- ]);
- $this->queryBuilder->execute();
+ ])
+ ->execute();
}
- $this->queryBuilder->resetQueryParts();
if ($firstResult !== null) {
$this->queryBuilder->setFirstResult($firstResult);
@@ -82,13 +85,19 @@ class QueryBuilderTest extends \Test\TestCase {
->orderBy('configkey', 'ASC');
$query = $this->queryBuilder->execute();
- $this->assertSame(sizeof($expectedSet), $query->rowCount());
- $this->assertEquals($expectedSet, $query->fetchAll());
+ $rows = [];
+ while ($row = $query->fetch()) {
+ $rows[] = $row;
+ }
+ $query->closeCursor();
- $this->queryBuilder->delete('*PREFIX*appconfig')
- ->where($eB->eq('appid', $eB->literal('testFirstResult')));
+ $this->assertCount(sizeof($expectedSet), $rows);
+ $this->assertEquals($expectedSet, $rows);
- $query = $this->queryBuilder->execute();
+ $qB = $this->connection->getQueryBuilder();
+ $qB->delete('*PREFIX*appconfig')
+ ->where($eB->eq('appid', $eB->literal('testFirstResult')))
+ ->execute();
}
public function dataMaxResults() {