Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jun 29, 2024
1 parent 35a82f6 commit 70b8b9d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Expression\JsonExpression;
use Yiisoft\Db\Query\Query;
Expand Down Expand Up @@ -792,11 +793,21 @@ public function testJsonOverlapsConditionBuilder(): void
);
$this->assertSame([':qp0' => '[1,2,3]'], $params);

// Test column as Expression
$params = [];
$sql = $qb->buildExpression(new JsonOverlapsCondition(new Expression('column'), [1, 2, 3]), $params);

$this->assertSame(
'EXISTS(SELECT value FROM json_each(column) INTERSECT SELECT value FROM json_each(:qp0))=1',
$sql
);
$this->assertSame([':qp0' => '[1,2,3]'], $params);

$db->close();
}

/** @dataProvider \Yiisoft\Db\Sqlite\Tests\Provider\QueryBuilderProvider::overlapsCondition */
public function testOverlapsCondition(iterable|ExpressionInterface $values, int $expectedCount): void
public function testJsonOverlapsCondition(iterable|ExpressionInterface $values, int $expectedCount): void
{
$db = $this->getConnection(true);

Expand All @@ -811,7 +822,7 @@ public function testOverlapsCondition(iterable|ExpressionInterface $values, int
}

/** @dataProvider \Yiisoft\Db\Sqlite\Tests\Provider\QueryBuilderProvider::overlapsCondition */
public function testOverlapsConditionOperator(iterable|ExpressionInterface $values, int $expectedCount): void
public function testJsonOverlapsConditionOperator(iterable|ExpressionInterface $values, int $expectedCount): void
{
$db = $this->getConnection(true);

Expand Down

0 comments on commit 70b8b9d

Please sign in to comment.