5
5
namespace Yiisoft \Db \Oracle \Tests ;
6
6
7
7
use PHPUnit \Framework \Attributes \DataProviderExternal ;
8
- use ReflectionException ;
9
- use Throwable ;
10
8
use Yiisoft \Db \Constant \ColumnType ;
11
9
use Yiisoft \Db \Constant \PseudoType ;
12
10
use Yiisoft \Db \Exception \Exception ;
13
- use Yiisoft \Db \Exception \InvalidArgumentException ;
14
- use Yiisoft \Db \Exception \InvalidCallException ;
15
- use Yiisoft \Db \Exception \InvalidConfigException ;
16
11
use Yiisoft \Db \Exception \NotSupportedException ;
17
12
use Yiisoft \Db \Oracle \Column \ColumnBuilder ;
18
13
use Yiisoft \Db \Oracle \IndexType ;
30
25
31
26
/**
32
27
* @group oracle
33
- *
34
- * @psalm-suppress PropertyNotSetInConstructor
35
28
*/
36
29
final class CommandTest extends CommonCommandTest
37
30
{
38
31
use TestTrait;
39
32
40
33
protected string $ upsertTestCharCast = 'CAST([[address]] AS VARCHAR(255)) ' ;
41
34
42
- /**
43
- * @throws Exception
44
- * @throws InvalidConfigException
45
- */
46
35
public function testAddDefaultValue (): void
47
36
{
48
37
$ db = $ this ->getConnection ();
@@ -108,11 +97,6 @@ public function testBatchInsertWithAutoincrement(): void
108
97
$ db ->close ();
109
98
}
110
99
111
- /**
112
- * @throws Exception
113
- * @throws InvalidConfigException
114
- * @throws Throwable
115
- */
116
100
public function testCLOBStringInsertion (): void
117
101
{
118
102
$ db = $ this ->getConnection ();
@@ -142,11 +126,6 @@ public function testCLOBStringInsertion(): void
142
126
$ db ->close ();
143
127
}
144
128
145
- /**
146
- * @throws Exception
147
- * @throws InvalidConfigException
148
- * @throws Throwable
149
- */
150
129
public function testCreateTable (): void
151
130
{
152
131
$ db = $ this ->getConnection (true );
@@ -188,11 +167,6 @@ public function testCreateTable(): void
188
167
$ db ->close ();
189
168
}
190
169
191
- /**
192
- * @throws Exception
193
- * @throws InvalidConfigException
194
- * @throws Throwable
195
- */
196
170
public function testCreateView (): void
197
171
{
198
172
$ db = $ this ->getConnection ();
@@ -251,10 +225,6 @@ public function testCreateView(): void
251
225
$ db ->close ();
252
226
}
253
227
254
- /**
255
- * @throws Exception
256
- * @throws InvalidConfigException
257
- */
258
228
public function testDropDefaultValue (): void
259
229
{
260
230
$ db = $ this ->getConnection ();
@@ -288,12 +258,6 @@ public function testDropTableIfExistsWithNonExistTable(): void
288
258
$ this ->markTestSkipped ('Oracle doesn \'t support "IF EXISTS" option on drop table. ' );
289
259
}
290
260
291
- /**
292
- * @throws Exception
293
- * @throws InvalidConfigException
294
- * @throws ReflectionException
295
- * @throws Throwable
296
- */
297
261
public function testExecuteWithTransaction (): void
298
262
{
299
263
$ db = $ this ->getConnection (true );
@@ -345,24 +309,12 @@ public function testExecuteWithTransaction(): void
345
309
$ db ->close ();
346
310
}
347
311
348
- /**
349
- * @dataProvider \Yiisoft\Db\Oracle\Tests\Provider\CommandProvider::rawSql
350
- *
351
- * @throws Exception
352
- * @throws InvalidConfigException
353
- * @throws NotSupportedException
354
- */
312
+ #[DataProviderExternal(CommandProvider::class, 'rawSql ' )]
355
313
public function testGetRawSql (string $ sql , array $ params , string $ expectedRawSql ): void
356
314
{
357
315
parent ::testGetRawSql ($ sql , $ params , $ expectedRawSql );
358
316
}
359
317
360
- /**
361
- * @throws Exception
362
- * @throws InvalidCallException
363
- * @throws InvalidConfigException
364
- * @throws Throwable
365
- */
366
318
public function testsInsertQueryAsColumnValue (): void
367
319
{
368
320
$ db = $ this ->getConnection (true );
@@ -399,12 +351,6 @@ public function testsInsertQueryAsColumnValue(): void
399
351
$ db ->close ();
400
352
}
401
353
402
- /**
403
- * @throws Exception
404
- * @throws InvalidCallException
405
- * @throws InvalidConfigException
406
- * @throws Throwable
407
- */
408
354
public function testInsertWithReturningPksWithPrimaryKeyString (): void
409
355
{
410
356
$ db = $ this ->getConnection ();
@@ -451,11 +397,6 @@ public function testInsertWithReturningPksWithPrimaryKeySignedDecimal(): void
451
397
$ db ->close ();
452
398
}
453
399
454
- /**
455
- * @throws Exception
456
- * @throws InvalidConfigException
457
- * @throws Throwable
458
- */
459
400
public function testInsertSelectAlias (): void
460
401
{
461
402
$ db = $ this ->getConnection ();
@@ -510,13 +451,7 @@ public function testInsertSelectAlias(): void
510
451
$ db ->close ();
511
452
}
512
453
513
- /**
514
- * @dataProvider \Yiisoft\Db\Oracle\Tests\Provider\CommandProvider::insertVarbinary
515
- *
516
- * @throws Exception
517
- * @throws InvalidConfigException
518
- * @throws Throwable
519
- */
454
+ #[DataProviderExternal(CommandProvider::class, 'insertVarbinary ' )]
520
455
public function testInsertVarbinary (mixed $ expectedData , mixed $ testData ): void
521
456
{
522
457
$ db = $ this ->getConnection (true );
@@ -537,12 +472,6 @@ public function testInsertVarbinary(mixed $expectedData, mixed $testData): void
537
472
$ db ->close ();
538
473
}
539
474
540
- /**
541
- * @throws Exception
542
- * @throws InvalidCallException
543
- * @throws InvalidConfigException
544
- * @throws Throwable
545
- */
546
475
public function testNoTablenameReplacement (): void
547
476
{
548
477
$ db = $ this ->getConnection (true );
@@ -592,13 +521,7 @@ public function testNoTablenameReplacement(): void
592
521
$ db ->close ();
593
522
}
594
523
595
- /**
596
- * @dataProvider \Yiisoft\Db\Oracle\Tests\Provider\CommandProvider::update
597
- *
598
- * @throws Exception
599
- * @throws InvalidConfigException
600
- * @throws Throwable
601
- */
524
+ #[DataProviderExternal(CommandProvider::class, 'update ' )]
602
525
public function testUpdate (
603
526
string $ table ,
604
527
array $ columns ,
@@ -610,25 +533,46 @@ public function testUpdate(
610
533
parent ::testUpdate ($ table , $ columns , $ conditions , $ params , $ expectedValues , $ expectedCount );
611
534
}
612
535
613
- /**
614
- * @dataProvider \Yiisoft\Db\Oracle\Tests\Provider\CommandProvider::upsert
615
- *
616
- * @throws Exception
617
- * @throws InvalidConfigException
618
- * @throws Throwable
619
- */
536
+ #[DataProviderExternal(CommandProvider::class, 'upsert ' )]
620
537
public function testUpsert (array $ firstData , array $ secondData ): void
621
538
{
622
539
parent ::testUpsert ($ firstData , $ secondData );
623
540
}
624
541
625
- /**
626
- * @throws InvalidConfigException
627
- * @throws InvalidArgumentException
628
- * @throws NotSupportedException
629
- * @throws Exception
630
- * @throws Throwable
631
- */
542
+ public function testUpsertWithReturningPks (): void
543
+ {
544
+ $ db = $ this ->getConnection ();
545
+ $ command = $ db ->createCommand ();
546
+
547
+ $ this ->expectException (NotSupportedException::class);
548
+ $ this ->expectExceptionMessage ('Yiisoft\Db\Oracle\DMLQueryBuilder::upsertWithReturningPks is not supported by Oracle. ' );
549
+
550
+ $ command->
upsertWithReturningPks (
'{{customer}} ' , [
'name ' =>
'test_1 ' ,
'email ' =>
'[email protected] ' ]);
551
+ }
552
+
553
+ public function testUpsertWithReturningPksEmptyValues ()
554
+ {
555
+ $ db = $ this ->getConnection ();
556
+ $ command = $ db ->createCommand ();
557
+
558
+ $ this ->expectException (NotSupportedException::class);
559
+ $ this ->expectExceptionMessage ('Yiisoft\Db\Oracle\DMLQueryBuilder::upsertWithReturningPks is not supported by Oracle. ' );
560
+
561
+ $ command ->upsertWithReturningPks ('null_values ' , []);
562
+ }
563
+
564
+ public function testUpsertWithReturningPksWithPhpTypecasting (): void
565
+ {
566
+ $ db = $ this ->getConnection ();
567
+
568
+ $ this ->expectException (NotSupportedException::class);
569
+ $ this ->expectExceptionMessage ('Yiisoft\Db\Oracle\DMLQueryBuilder::upsertWithReturningPks is not supported by Oracle. ' );
570
+
571
+ $ db ->createCommand ()
572
+ ->withPhpTypecasting ()
573
+ ->upsertWithReturningPks ('notauto_pk ' , ['id_1 ' => 1 , 'id_2 ' => 2.5 , 'type ' => 'test1 ' ]);
574
+ }
575
+
632
576
public function testQueryScalarWithBlob (): void
633
577
{
634
578
$ db = $ this ->getConnection (true );
0 commit comments