6
6
7
7
use PHPUnit \Framework \Attributes \DataProviderExternal ;
8
8
use Throwable ;
9
- use Yiisoft \Db \Constant \ColumnType ;
10
9
use Yiisoft \Db \Exception \Exception ;
11
10
use Yiisoft \Db \Exception \InvalidArgumentException ;
12
11
use Yiisoft \Db \Exception \InvalidConfigException ;
@@ -28,6 +27,11 @@ final class QueryBuilderTest extends CommonQueryBuilderTest
28
27
{
29
28
use TestTrait;
30
29
30
+ public function getBuildColumnDefinitionProvider (): array
31
+ {
32
+ return QueryBuilderProvider::buildColumnDefinition ();
33
+ }
34
+
31
35
/**
32
36
* @throws Exception
33
37
* @throws InvalidConfigException
@@ -99,24 +103,10 @@ public function testAddUnique(string $name, string $table, array|string $columns
99
103
parent ::testAddUnique ($ name , $ table , $ columns , $ expected );
100
104
}
101
105
102
- /**
103
- * @throws Exception
104
- * @throws InvalidConfigException
105
- */
106
- public function testAlterColumn (): void
106
+ #[DataProviderExternal(QueryBuilderProvider::class, 'alterColumn ' )]
107
+ public function testAlterColumn (string |ColumnSchemaInterface $ type , string $ expected ): void
107
108
{
108
- $ db = $ this ->getConnection ();
109
-
110
- $ qb = $ db ->getQueryBuilder ();
111
-
112
- $ this ->assertSame (
113
- <<<SQL
114
- ALTER TABLE "customer" MODIFY "email" VARCHAR2(255)
115
- SQL ,
116
- $ qb ->alterColumn ('customer ' , 'email ' , ColumnType::STRING ),
117
- );
118
-
119
- $ db ->close ();
109
+ parent ::testAlterColumn ($ type , $ expected );
120
110
}
121
111
122
112
/**
@@ -312,11 +302,11 @@ public function testCreateTable(): void
312
302
$ this ->assertSame (
313
303
<<<SQL
314
304
CREATE TABLE "test" (
315
- \t"id" NUMBER (10) GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY,
316
- \t"name" VARCHAR2 (255) NOT NULL,
317
- \t"email" VARCHAR2 (255) NOT NULL,
318
- \t"status" NUMBER (10) NOT NULL,
319
- \t"created_at" TIMESTAMP(0) NOT NULL
305
+ \t"id" number (10) GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
306
+ \t"name" varchar2 (255) NOT NULL,
307
+ \t"email" varchar2 (255) NOT NULL,
308
+ \t"status" number (10) NOT NULL,
309
+ \t"created_at" timestamp NOT NULL
320
310
)
321
311
SQL ,
322
312
$ qb ->createTable (
0 commit comments