From ae55fefcf6e203a1f2e42ca2f860caed858e78fb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 24 Jul 2017 12:01:35 +0200 Subject: [PATCH] Fix querybuilder and functionbuilder tests Signed-off-by: Joas Schilling --- .../DB/QueryBuilder/FunctionBuilderTest.php | 8 +++ .../lib/DB/QueryBuilder/QueryBuilderTest.php | 50 +++++++++---------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php index c270e105fc1..e89da0fbc92 100644 --- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php @@ -44,6 +44,8 @@ class FunctionBuilderTest extends TestCase { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->concat($query->createNamedParameter('foo'), new Literal("'bar'"))); + $query->from('appconfig') + ->setMaxResults(1); $this->assertEquals('foobar', $query->execute()->fetchColumn()); } @@ -52,6 +54,8 @@ class FunctionBuilderTest extends TestCase { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->md5($query->createNamedParameter('foobar'))); + $query->from('appconfig') + ->setMaxResults(1); $this->assertEquals(md5('foobar'), $query->execute()->fetchColumn()); } @@ -60,6 +64,8 @@ class FunctionBuilderTest extends TestCase { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->substring($query->createNamedParameter('foobar'), new Literal(2), $query->createNamedParameter(2))); + $query->from('appconfig') + ->setMaxResults(1); $this->assertEquals('oo', $query->execute()->fetchColumn()); } @@ -68,6 +74,8 @@ class FunctionBuilderTest extends TestCase { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->substring($query->createNamedParameter('foobar'), new Literal(2))); + $query->from('appconfig') + ->setMaxResults(1); $this->assertEquals('oobar', $query->execute()->fetchColumn()); } diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index 150c772b26c..e264fde6ec7 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -472,15 +472,15 @@ class QueryBuilderTest extends \Test\TestCase { public function dataFrom() { return [ ['data', null, null, null, [['table' => '`*PREFIX*data`', 'alias' => null]], '`*PREFIX*data`'], - ['data', 't', null, null, [['table' => '`*PREFIX*data`', 'alias' => 't']], '`*PREFIX*data` t'], + ['data', 't', null, null, [['table' => '`*PREFIX*data`', 'alias' => '`t`']], '`*PREFIX*data` `t`'], ['data1', null, 'data2', null, [ ['table' => '`*PREFIX*data1`', 'alias' => null], ['table' => '`*PREFIX*data2`', 'alias' => null] ], '`*PREFIX*data1`, `*PREFIX*data2`'], ['data', 't1', 'data', 't2', [ - ['table' => '`*PREFIX*data`', 'alias' => 't1'], - ['table' => '`*PREFIX*data`', 'alias' => 't2'] - ], '`*PREFIX*data` t1, `*PREFIX*data` t2'], + ['table' => '`*PREFIX*data`', 'alias' => '`t1`'], + ['table' => '`*PREFIX*data`', 'alias' => '`t2`'] + ], '`*PREFIX*data` `t1`, `*PREFIX*data` `t2`'], ]; } @@ -515,18 +515,18 @@ class QueryBuilderTest extends \Test\TestCase { return [ [ 'd1', 'data2', null, null, - ['d1' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], - '`*PREFIX*data1` d1 INNER JOIN `*PREFIX*data2` ON ' + ['`d1`' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], + '`*PREFIX*data1` `d1` INNER JOIN `*PREFIX*data2` ON ' ], [ 'd1', 'data2', 'd2', null, - ['d1' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]], - '`*PREFIX*data1` d1 INNER JOIN `*PREFIX*data2` d2 ON ' + ['`d1`' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '`d2`', 'joinCondition' => null]]], + '`*PREFIX*data1` `d1` INNER JOIN `*PREFIX*data2` `d2` ON ' ], [ - 'd1', 'data2', 'd2', 'd1.`field1` = d2.`field2`', - ['d1' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]], - '`*PREFIX*data1` d1 INNER JOIN `*PREFIX*data2` d2 ON d1.`field1` = d2.`field2`' + 'd1', 'data2', 'd2', '`d1`.`field1` = `d2`.`field2`', + ['`d1`' => [['joinType' => 'inner', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '`d2`', 'joinCondition' => '`d1`.`field1` = `d2`.`field2`']]], + '`*PREFIX*data1` `d1` INNER JOIN `*PREFIX*data2` `d2` ON `d1`.`field1` = `d2`.`field2`' ], ]; @@ -596,18 +596,18 @@ class QueryBuilderTest extends \Test\TestCase { return [ [ 'd1', 'data2', null, null, - ['d1' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], - '`*PREFIX*data1` d1 LEFT JOIN `*PREFIX*data2` ON ' + ['`d1`' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], + '`*PREFIX*data1` `d1` LEFT JOIN `*PREFIX*data2` ON ' ], [ 'd1', 'data2', 'd2', null, - ['d1' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]], - '`*PREFIX*data1` d1 LEFT JOIN `*PREFIX*data2` d2 ON ' + ['`d1`' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '`d2`', 'joinCondition' => null]]], + '`*PREFIX*data1` `d1` LEFT JOIN `*PREFIX*data2` `d2` ON ' ], [ - 'd1', 'data2', 'd2', 'd1.`field1` = d2.`field2`', - ['d1' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]], - '`*PREFIX*data1` d1 LEFT JOIN `*PREFIX*data2` d2 ON d1.`field1` = d2.`field2`' + 'd1', 'data2', 'd2', '`d1`.`field1` = `d2`.`field2`', + ['`d1`' => [['joinType' => 'left', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '`d2`', 'joinCondition' => '`d1`.`field1` = `d2`.`field2`']]], + '`*PREFIX*data1` `d1` LEFT JOIN `*PREFIX*data2` `d2` ON `d1`.`field1` = `d2`.`field2`' ], ]; } @@ -646,18 +646,18 @@ class QueryBuilderTest extends \Test\TestCase { return [ [ 'd1', 'data2', null, null, - ['d1' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], - '`*PREFIX*data1` d1 RIGHT JOIN `*PREFIX*data2` ON ' + ['`d1`' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => null, 'joinCondition' => null]]], + '`*PREFIX*data1` `d1` RIGHT JOIN `*PREFIX*data2` ON ' ], [ 'd1', 'data2', 'd2', null, - ['d1' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => null]]], - '`*PREFIX*data1` d1 RIGHT JOIN `*PREFIX*data2` d2 ON ' + ['`d1`' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '`d2`', 'joinCondition' => null]]], + '`*PREFIX*data1` `d1` RIGHT JOIN `*PREFIX*data2` `d2` ON ' ], [ - 'd1', 'data2', 'd2', 'd1.`field1` = d2.`field2`', - ['d1' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => 'd2', 'joinCondition' => 'd1.`field1` = d2.`field2`']]], - '`*PREFIX*data1` d1 RIGHT JOIN `*PREFIX*data2` d2 ON d1.`field1` = d2.`field2`' + 'd1', 'data2', 'd2', '`d1`.`field1` = `d2`.`field2`', + ['`d1`' => [['joinType' => 'right', 'joinTable' => '`*PREFIX*data2`', 'joinAlias' => '`d2`', 'joinCondition' => '`d1`.`field1` = `d2`.`field2`']]], + '`*PREFIX*data1` `d1` RIGHT JOIN `*PREFIX*data2` `d2` ON `d1`.`field1` = `d2`.`field2`' ], ]; } -- 2.39.5