diff options
author | Joas Schilling <coding@schilljs.com> | 2017-07-24 12:01:35 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-08-02 09:48:16 +0200 |
commit | 293dea0625ba76969c05fda47b2f5400bbaf523e (patch) | |
tree | 9de88205439db8d6ff5d1fafcb65c7e90eb577be /tests/lib/DB | |
parent | bb58667511b79c2da47be0c08f82527b4088e9fb (diff) | |
download | nextcloud-server-293dea0625ba76969c05fda47b2f5400bbaf523e.tar.gz nextcloud-server-293dea0625ba76969c05fda47b2f5400bbaf523e.zip |
Fix querybuilder and functionbuilder tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/DB')
-rw-r--r-- | tests/lib/DB/QueryBuilder/FunctionBuilderTest.php | 8 | ||||
-rw-r--r-- | tests/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`' ], ]; } |