66
77use JsonException ;
88use PHPUnit \Framework \Attributes \DataProviderExternal ;
9- use Yiisoft \Db \Constant \ColumnType ;
109use Yiisoft \Db \Exception \Exception ;
1110use Yiisoft \Db \Exception \InvalidArgumentException ;
1211use Yiisoft \Db \Exception \InvalidConfigException ;
1817use Yiisoft \Db \Query \QueryInterface ;
1918use Yiisoft \Db \QueryBuilder \Condition \JsonOverlapsCondition ;
2019use Yiisoft \Db \Schema \Column \ColumnSchemaInterface ;
21- use Yiisoft \Db \Sqlite \Column ;
20+ use Yiisoft \Db \Sqlite \Column \ ColumnBuilder ;
2221use Yiisoft \Db \Sqlite \Tests \Provider \QueryBuilderProvider ;
2322use Yiisoft \Db \Sqlite \Tests \Support \TestTrait ;
2423use Yiisoft \Db \Tests \Common \CommonQueryBuilderTest ;
@@ -32,6 +31,11 @@ final class QueryBuilderTest extends CommonQueryBuilderTest
3231{
3332 use TestTrait;
3433
34+ public function getBuildColumnDefinitionProvider (): array
35+ {
36+ return QueryBuilderProvider::buildColumnDefinition ();
37+ }
38+
3539 /**
3640 * @throws Exception
3741 * @throws InvalidConfigException
@@ -162,20 +166,13 @@ public function testAddUnique(string $name, string $table, array|string $columns
162166 $ qb ->addUnique ($ table , $ name , $ columns );
163167 }
164168
165- /**
166- * @throws Exception
167- * @throws InvalidConfigException
168- */
169- public function testAlterColumn (): void
169+ #[DataProviderExternal(QueryBuilderProvider::class, 'alterColumn ' )]
170+ public function testAlterColumn (string |ColumnSchemaInterface $ type , string $ expected ): void
170171 {
171- $ db = $ this ->getConnection ();
172-
173- $ qb = $ db ->getQueryBuilder ();
174-
175172 $ this ->expectException (NotSupportedException::class);
176173 $ this ->expectExceptionMessage ('Yiisoft\Db\Sqlite\DDLQueryBuilder::alterColumn is not supported by SQLite. ' );
177174
178- $ qb -> alterColumn ( ' customer ' , ' email ' , ColumnType:: STRING );
175+ parent :: testAlterColumn ( $ type , $ expected );
179176 }
180177
181178 /**
@@ -753,16 +750,16 @@ public function testUpsertExecute(
753750 public function testJsonColumn ()
754751 {
755752 $ qb = $ this ->getConnection ()->getQueryBuilder ();
756- $ columnSchemaBuilder = new Column (ColumnType:: JSON );
753+ $ column = ColumnBuilder:: json ( );
757754
758755 $ this ->assertSame (
759756 'ALTER TABLE `json_table` ADD `json_col` json ' ,
760- $ qb ->addColumn ('json_table ' , 'json_col ' , $ columnSchemaBuilder -> asString () ),
757+ $ qb ->addColumn ('json_table ' , 'json_col ' , $ column ),
761758 );
762759
763760 $ this ->assertSame (
764761 "CREATE TABLE `json_table` ( \n\t`json_col` json \n) " ,
765- $ qb ->createTable ('json_table ' , ['json_col ' => $ columnSchemaBuilder ]),
762+ $ qb ->createTable ('json_table ' , ['json_col ' => $ column ]),
766763 );
767764
768765 $ this ->assertSame (
0 commit comments