Skip to content

Make TestTrait::getDriverName() static #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,22 @@ public static function prepareValue(): array

return $values;
}

public static function caseExpressionBuilder(): array
{
$data = parent::caseExpressionBuilder();

$data['with case expression'] = [
$data['with case expression'][0]->else(
new Expression('to_number(:qp0)', [':qp0' => $param = new Param(4, DataType::INTEGER)])
),
'CASE (1 + 2) WHEN 1 THEN 1 WHEN 2 THEN 2 WHEN 3 THEN (2 + 1) ELSE to_number(:qp0) END',
[':qp0' => $param],
3,
];
$data['without case expression'][1] = 'CASE WHEN "column_name" = :qp0 THEN :qp1'
. ' WHEN "column_name" = 2 THEN (SELECT :pv2 FROM DUAL) END';

return $data;
}
}
11 changes: 11 additions & 0 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Db\Exception\Exception;
use InvalidArgumentException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\CaseExpression;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Oracle\Tests\Provider\QueryBuilderProvider;
use Yiisoft\Db\Oracle\Tests\Support\TestTrait;
Expand Down Expand Up @@ -568,4 +569,14 @@ public function testDropTable(string $expected, ?bool $ifExists, ?bool $cascade)

parent::testDropTable($expected, $ifExists, $cascade);
}

#[DataProviderExternal(QueryBuilderProvider::class, 'caseExpressionBuilder')]
public function testCaseExpressionBuilder(
CaseExpression $case,
string $expectedSql,
array $expectedParams,
string|int $expectedResult,
): void {
parent::testCaseExpressionBuilder($case, $expectedSql, $expectedParams, $expectedResult);
}
}
2 changes: 1 addition & 1 deletion tests/Support/TestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function getDsn(): string
return $this->dsn;
}

protected function getDriverName(): string
protected static function getDriverName(): string
{
return 'oci';
}
Expand Down