aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php')
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php49
1 files changed, 26 insertions, 23 deletions
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
index c14c55e6d02..1f84ebfbec1 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -10,6 +11,8 @@ namespace Test\DB\QueryBuilder;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder as DoctrineExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IDBConnection;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -27,7 +30,7 @@ class ExpressionBuilderTest extends TestCase {
/** @var DoctrineExpressionBuilder */
protected $doctrineExpressionBuilder;
- /** @var \OCP\IDBConnection */
+ /** @var IDBConnection */
protected $connection;
/** @var \Doctrine\DBAL\Connection */
@@ -39,8 +42,8 @@ class ExpressionBuilderTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
- $this->internalConnection = \OC::$server->get(\OC\DB\Connection::class);
+ $this->connection = Server::get(IDBConnection::class);
+ $this->internalConnection = Server::get(\OC\DB\Connection::class);
$this->logger = $this->createMock(LoggerInterface::class);
$queryBuilder = $this->createMock(IQueryBuilder::class);
@@ -50,8 +53,8 @@ class ExpressionBuilderTest extends TestCase {
$this->doctrineExpressionBuilder = new DoctrineExpressionBuilder($this->internalConnection);
}
- public function dataComparison() {
- $valueSets = $this->dataComparisons();
+ public static function dataComparison(): array {
+ $valueSets = self::dataComparisons();
$comparisonOperators = ['=', '<>', '<', '>', '<=', '>='];
$testSets = [];
@@ -64,7 +67,6 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparison
*
* @param string $comparison
* @param mixed $input1
@@ -72,6 +74,7 @@ class ExpressionBuilderTest extends TestCase {
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparison')]
public function testComparison($comparison, $input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -82,7 +85,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataComparisons() {
+ public static function dataComparisons(): array {
return [
['value', false, 'value', false],
['value', false, 'value', true],
@@ -92,13 +95,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparisons
*
* @param mixed $input1
* @param bool $isInput1Literal
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
public function testEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -110,13 +113,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparisons
*
* @param mixed $input1
* @param bool $isInput1Literal
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
public function testNotEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -128,13 +131,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparisons
*
* @param mixed $input1
* @param bool $isInput1Literal
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
public function testLowerThan($input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -146,13 +149,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparisons
*
* @param mixed $input1
* @param bool $isInput1Literal
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
public function testLowerThanEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -164,13 +167,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparisons
*
* @param mixed $input1
* @param bool $isInput1Literal
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
public function testGreaterThan($input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -182,13 +185,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataComparisons
*
* @param mixed $input1
* @param bool $isInput1Literal
* @param mixed $input2
* @param bool $isInput2Literal
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataComparisons')]
public function testGreaterThanEquals($input1, $isInput1Literal, $input2, $isInput2Literal): void {
[$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal);
[$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal);
@@ -213,7 +216,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataLike() {
+ public static function dataLike(): array {
return [
['value', false],
['value', true],
@@ -221,11 +224,11 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataLike
*
* @param mixed $input
* @param bool $isLiteral
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataLike')]
public function testLike($input, $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
@@ -236,11 +239,11 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataLike
*
* @param mixed $input
* @param bool $isLiteral
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataLike')]
public function testNotLike($input, $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
@@ -250,7 +253,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataIn() {
+ public static function dataIn(): array {
return [
['value', false],
['value', true],
@@ -260,11 +263,11 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataIn
*
* @param mixed $input
* @param bool $isLiteral
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataIn')]
public function testIn($input, $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
@@ -275,11 +278,11 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataIn
*
* @param mixed $input
* @param bool $isLiteral
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataIn')]
public function testNotIn($input, $isLiteral): void {
[$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral);
@@ -317,7 +320,7 @@ class ExpressionBuilderTest extends TestCase {
return [$doctrineInput, $ocInput];
}
- public function dataLiteral() {
+ public static function dataLiteral(): array {
return [
['value', null],
['1', null],
@@ -329,11 +332,11 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataLiteral
*
* @param mixed $input
* @param string|null $type
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataLiteral')]
public function testLiteral($input, $type): void {
/** @var \OC\DB\QueryBuilder\Literal $actual */
$actual = $this->expressionBuilder->literal($input, $type);
@@ -345,7 +348,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataClobComparisons() {
+ public static function dataClobComparisons(): array {
return [
['eq', '5', IQueryBuilder::PARAM_STR, false, 3],
['eq', '5', IQueryBuilder::PARAM_STR, true, 1],
@@ -373,13 +376,13 @@ class ExpressionBuilderTest extends TestCase {
}
/**
- * @dataProvider dataClobComparisons
* @param string $function
* @param mixed $value
* @param mixed $type
* @param bool $compareKeyToValue
* @param int $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataClobComparisons')]
public function testClobComparisons($function, $value, $type, $compareKeyToValue, $expected): void {
$appId = $this->getUniqueID('testing');
$this->createConfig($appId, 1, 4);