@@ -14,14 +14,52 @@ public function testGetTableFields(): void {
1414 /**
1515 * Test if the outer nested transaction detection works as expected
1616 */
17- public function testNestedTransaction (): void {
18- $ this ->getDB ()->transactionStart ();
19- $ this ->getDB ()->transactionStart ();
20- $ this ->getDB ()->transactionStart ();
21- $ this ->getDB ()->transactionRollback ();
22- $ this ->getDB ()->transactionRollback ();
23- $ this ->getDB ()->transactionRollback ();
24- self ::assertTrue (true );
17+ public function testNestedDryRun (): void {
18+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 100 )->where (['id ' => 1 ])->run ();
19+ $ this ->getDB ()->dryRun (function () {
20+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 101 )->where (['id ' => 1 ])->run ();
21+ $ this ->getDB ()->dryRun (function () {
22+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 102 )->where (['id ' => 1 ])->run ();
23+ $ this ->getDB ()->dryRun (function () {
24+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 103 )->where (['id ' => 1 ])->run ();
25+ self ::assertEquals (103 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
26+ });
27+ self ::assertEquals (102 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
28+ });
29+ self ::assertEquals (101 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
30+ });
31+ self ::assertEquals (100 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
32+ }
33+
34+ /**
35+ * Test if the outer nested transaction detection works as expected
36+ */
37+ public function testNestedTransactionWithException (): void {
38+ $ this ->expectExceptionMessage ('TEST ' );
39+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 100 )->where (['id ' => 1 ])->run ();
40+ $ this ->getDB ()->transaction (function () {
41+ try {
42+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 101 )->where (['id ' => 1 ])->run ();
43+ $ this ->getDB ()->transaction (function () {
44+ try {
45+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 102 )->where (['id ' => 1 ])->run ();
46+ $ this ->getDB ()->transaction (function () {
47+ try {
48+ $ this ->getDB ()->update ()->table ('test1 ' )->set ('field1 ' , 103 )->where (['id ' => 1 ])->run ();
49+ throw new RuntimeException ('TEST ' );
50+ } finally {
51+ self ::assertEquals (103 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
52+ }
53+ });
54+ } finally {
55+ self ::assertEquals (102 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
56+ }
57+ });
58+ } finally {
59+ self ::assertEquals (101 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
60+ }
61+ });
62+ self ::assertEquals (100 , $ this ->getDB ()->query ('SELECT field1 FROM test1 WHERE id=1 ' )->fetchColumn (0 ));
2563 }
2664
2765 public function testFetchRow (): void {
0 commit comments