diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php index 6518d4406f1..bbaaf376ca0 100644 --- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php @@ -1,5 +1,7 @@ connection = Server::get(IDBConnection::class); - $this->internalConnection = Server::get(\OC\DB\Connection::class); + $this->internalConnection = Server::get(Connection::class); $this->logger = $this->createMock(LoggerInterface::class); $queryBuilder = $this->createMock(IQueryBuilder::class); + $queryBuilder->method('func') + ->willReturn($this->createMock(IFunctionBuilder::class)); $this->expressionBuilder = new ExpressionBuilder($this->connection, $queryBuilder, $this->logger); @@ -67,16 +66,8 @@ class ExpressionBuilderTest extends TestCase { return $testSets; } - /** - * - * @param string $comparison - * @param mixed $input1 - * @param bool $isInput1Literal - * @param mixed $input2 - * @param bool $isInput2Literal - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dataComparison')] - public function testComparison($comparison, $input1, $isInput1Literal, $input2, $isInput2Literal): void { + #[DataProvider('dataComparison')] + public function testComparison(string $comparison, string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -95,15 +86,8 @@ class ExpressionBuilderTest extends TestCase { ]; } - /** - * - * @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 { + #[DataProvider('dataComparisons')] + public function testEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -113,15 +97,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @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 { + #[DataProvider('dataComparisons')] + public function testNotEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -131,15 +108,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @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 { + #[DataProvider('dataComparisons')] + public function testLowerThan(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -149,15 +119,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @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 { + #[DataProvider('dataComparisons')] + public function testLowerThanEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -167,15 +130,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @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 { + #[DataProvider('dataComparisons')] + public function testGreaterThan(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -185,15 +141,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @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 { + #[DataProvider('dataComparisons')] + public function testGreaterThanEquals(string $input1, bool $isInput1Literal, string $input2, bool $isInput2Literal): void { [$doctrineInput1, $ocInput1] = $this->helpWithLiteral($input1, $isInput1Literal); [$doctrineInput2, $ocInput2] = $this->helpWithLiteral($input2, $isInput2Literal); @@ -224,13 +173,8 @@ class ExpressionBuilderTest extends TestCase { ]; } - /** - * - * @param mixed $input - * @param bool $isLiteral - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dataLike')] - public function testLike($input, $isLiteral): void { + #[DataProvider('dataLike')] + public function testLike(string $input, bool $isLiteral): void { [$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral); $this->assertEquals( @@ -239,13 +183,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @param mixed $input - * @param bool $isLiteral - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dataLike')] - public function testNotLike($input, $isLiteral): void { + #[DataProvider('dataLike')] + public function testNotLike(string $input, bool $isLiteral): void { [$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral); $this->assertEquals( @@ -263,13 +202,8 @@ class ExpressionBuilderTest extends TestCase { ]; } - /** - * - * @param mixed $input - * @param bool $isLiteral - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dataIn')] - public function testIn($input, $isLiteral): void { + #[DataProvider('dataIn')] + public function testIn(string|array $input, bool $isLiteral): void { [$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral); $this->assertEquals( @@ -278,13 +212,8 @@ class ExpressionBuilderTest extends TestCase { ); } - /** - * - * @param mixed $input - * @param bool $isLiteral - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dataIn')] - public function testNotIn($input, $isLiteral): void { + #[DataProvider('dataIn')] + public function testNotIn(string|array $input, bool $isLiteral): void { [$doctrineInput, $ocInput] = $this->helpWithLiteral($input, $isLiteral); $this->assertEquals( @@ -293,7 +222,7 @@ class ExpressionBuilderTest extends TestCase { ); } - protected function helpWithLiteral($input, $isLiteral) { + protected function helpWithLiteral(string|array $input, bool $isLiteral) { if ($isLiteral) { if (is_array($input)) { $doctrineInput = array_map(function ($ident) { @@ -332,13 +261,8 @@ class ExpressionBuilderTest extends TestCase { ]; } - /** - * - * @param mixed $input - * @param string|null $type - */ - #[\PHPUnit\Framework\Attributes\DataProvider('dataLiteral')] - public function testLiteral($input, $type): void { + #[DataProvider('dataLiteral')] + public function testLiteral(string|int $input, string|int|null $type): void { /** @var Literal $actual */ $actual = $this->expressionBuilder->literal($input, $type); @@ -376,15 +300,8 @@ class ExpressionBuilderTest extends TestCase { ]; } - /** - * @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 { + #[DataProvider('dataClobComparisons')] + public function testClobComparisons(string $function, string|array $value, int $type, bool $compareKeyToValue, int $expected): void { $appId = $this->getUniqueID('testing'); $this->createConfig($appId, 1, 4); $this->createConfig($appId, 2, 5); @@ -419,7 +336,7 @@ class ExpressionBuilderTest extends TestCase { ->executeStatement(); } - protected function createConfig($appId, $key, $value) { + protected function createConfig(string $appId, int $key, int|string $value) { $query = $this->connection->getQueryBuilder(); $query->insert('appconfig') ->values([