55namespace Yiisoft \Db \Oracle \Tests ;
66
77use PHPUnit \Framework \Attributes \DataProviderExternal ;
8- use ReflectionException ;
9- use Throwable ;
108use Yiisoft \Db \Constant \ColumnType ;
119use Yiisoft \Db \Constant \PseudoType ;
1210use Yiisoft \Db \Exception \Exception ;
13- use Yiisoft \Db \Exception \InvalidArgumentException ;
14- use Yiisoft \Db \Exception \InvalidCallException ;
15- use Yiisoft \Db \Exception \InvalidConfigException ;
1611use Yiisoft \Db \Exception \NotSupportedException ;
1712use Yiisoft \Db \Oracle \Column \ColumnBuilder ;
1813use Yiisoft \Db \Oracle \IndexType ;
3025
3126/**
3227 * @group oracle
33- *
34- * @psalm-suppress PropertyNotSetInConstructor
3528 */
3629final class CommandTest extends CommonCommandTest
3730{
3831 use TestTrait;
3932
4033 protected string $ upsertTestCharCast = 'CAST([[address]] AS VARCHAR(255)) ' ;
4134
42- /**
43- * @throws Exception
44- * @throws InvalidConfigException
45- */
4635 public function testAddDefaultValue (): void
4736 {
4837 $ db = $ this ->getConnection ();
@@ -108,11 +97,6 @@ public function testBatchInsertWithAutoincrement(): void
10897 $ db ->close ();
10998 }
11099
111- /**
112- * @throws Exception
113- * @throws InvalidConfigException
114- * @throws Throwable
115- */
116100 public function testCLOBStringInsertion (): void
117101 {
118102 $ db = $ this ->getConnection ();
@@ -142,11 +126,6 @@ public function testCLOBStringInsertion(): void
142126 $ db ->close ();
143127 }
144128
145- /**
146- * @throws Exception
147- * @throws InvalidConfigException
148- * @throws Throwable
149- */
150129 public function testCreateTable (): void
151130 {
152131 $ db = $ this ->getConnection (true );
@@ -188,11 +167,6 @@ public function testCreateTable(): void
188167 $ db ->close ();
189168 }
190169
191- /**
192- * @throws Exception
193- * @throws InvalidConfigException
194- * @throws Throwable
195- */
196170 public function testCreateView (): void
197171 {
198172 $ db = $ this ->getConnection ();
@@ -251,10 +225,6 @@ public function testCreateView(): void
251225 $ db ->close ();
252226 }
253227
254- /**
255- * @throws Exception
256- * @throws InvalidConfigException
257- */
258228 public function testDropDefaultValue (): void
259229 {
260230 $ db = $ this ->getConnection ();
@@ -288,12 +258,6 @@ public function testDropTableIfExistsWithNonExistTable(): void
288258 $ this ->markTestSkipped ('Oracle doesn \'t support "IF EXISTS" option on drop table. ' );
289259 }
290260
291- /**
292- * @throws Exception
293- * @throws InvalidConfigException
294- * @throws ReflectionException
295- * @throws Throwable
296- */
297261 public function testExecuteWithTransaction (): void
298262 {
299263 $ db = $ this ->getConnection (true );
@@ -345,24 +309,12 @@ public function testExecuteWithTransaction(): void
345309 $ db ->close ();
346310 }
347311
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 ' )]
355313 public function testGetRawSql (string $ sql , array $ params , string $ expectedRawSql ): void
356314 {
357315 parent ::testGetRawSql ($ sql , $ params , $ expectedRawSql );
358316 }
359317
360- /**
361- * @throws Exception
362- * @throws InvalidCallException
363- * @throws InvalidConfigException
364- * @throws Throwable
365- */
366318 public function testsInsertQueryAsColumnValue (): void
367319 {
368320 $ db = $ this ->getConnection (true );
@@ -399,12 +351,6 @@ public function testsInsertQueryAsColumnValue(): void
399351 $ db ->close ();
400352 }
401353
402- /**
403- * @throws Exception
404- * @throws InvalidCallException
405- * @throws InvalidConfigException
406- * @throws Throwable
407- */
408354 public function testInsertWithReturningPksWithPrimaryKeyString (): void
409355 {
410356 $ db = $ this ->getConnection ();
@@ -451,11 +397,6 @@ public function testInsertWithReturningPksWithPrimaryKeySignedDecimal(): void
451397 $ db ->close ();
452398 }
453399
454- /**
455- * @throws Exception
456- * @throws InvalidConfigException
457- * @throws Throwable
458- */
459400 public function testInsertSelectAlias (): void
460401 {
461402 $ db = $ this ->getConnection ();
@@ -510,13 +451,7 @@ public function testInsertSelectAlias(): void
510451 $ db ->close ();
511452 }
512453
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 ' )]
520455 public function testInsertVarbinary (mixed $ expectedData , mixed $ testData ): void
521456 {
522457 $ db = $ this ->getConnection (true );
@@ -537,12 +472,6 @@ public function testInsertVarbinary(mixed $expectedData, mixed $testData): void
537472 $ db ->close ();
538473 }
539474
540- /**
541- * @throws Exception
542- * @throws InvalidCallException
543- * @throws InvalidConfigException
544- * @throws Throwable
545- */
546475 public function testNoTablenameReplacement (): void
547476 {
548477 $ db = $ this ->getConnection (true );
@@ -592,13 +521,7 @@ public function testNoTablenameReplacement(): void
592521 $ db ->close ();
593522 }
594523
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 ' )]
602525 public function testUpdate (
603526 string $ table ,
604527 array $ columns ,
@@ -610,25 +533,46 @@ public function testUpdate(
610533 parent ::testUpdate ($ table , $ columns , $ conditions , $ params , $ expectedValues , $ expectedCount );
611534 }
612535
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 ' )]
620537 public function testUpsert (array $ firstData , array $ secondData ): void
621538 {
622539 parent ::testUpsert ($ firstData , $ secondData );
623540 }
624541
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+
632576 public function testQueryScalarWithBlob (): void
633577 {
634578 $ db = $ this ->getConnection (true );
0 commit comments