2121 * @group DatabaseLive
2222 *
2323 * @internal
24+ *
25+ * @no-final
2426 */
25- final class TransactionTest extends CIUnitTestCase
27+ class TransactionDBDebugTrueTest extends CIUnitTestCase
2628{
2729 use DatabaseTestTrait;
2830
@@ -55,13 +57,38 @@ protected function enableDBDebug(): void
5557 $ this ->setPrivateProperty ($ this ->db , 'DBDebug ' , true );
5658 }
5759
58- public function testTransStartDBDebugTrue ()
60+ public function testTransStart ()
61+ {
62+ $ builder = $ this ->db ->table ('job ' );
63+
64+ $ this ->db ->transStart ();
65+
66+ $ jobData = [
67+ 'name ' => 'Grocery Sales ' ,
68+ 'description ' => 'Discount! ' ,
69+ ];
70+ $ builder ->insert ($ jobData );
71+
72+ // Duplicate entry '1' for key 'PRIMARY'
73+ $ jobData = [
74+ 'id ' => 1 ,
75+ 'name ' => 'Comedian ' ,
76+ 'description ' => 'Theres something in your teeth ' ,
77+ ];
78+ $ builder ->insert ($ jobData );
79+
80+ $ this ->db ->transComplete ();
81+
82+ $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Grocery Sales ' ]);
83+ }
84+
85+ public function testTransStartTransException ()
5986 {
6087 $ builder = $ this ->db ->table ('job ' );
6188 $ e = null ;
6289
6390 try {
64- $ this ->db ->transStart ();
91+ $ this ->db ->transException ( true )-> transStart ();
6592
6693 $ jobData = [
6794 'name ' => 'Grocery Sales ' ,
@@ -86,43 +113,8 @@ public function testTransStartDBDebugTrue()
86113 $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Grocery Sales ' ]);
87114 }
88115
89- public function testTransStartDBDebugFalse ()
116+ public function testTransStrictTrue ()
90117 {
91- $ this ->disableDBDebug ();
92-
93- $ builder = $ this ->db ->table ('job ' );
94-
95- $ this ->db ->transStart ();
96-
97- $ jobData = [
98- 'name ' => 'Grocery Sales ' ,
99- 'description ' => 'Discount! ' ,
100- ];
101- $ builder ->insert ($ jobData );
102-
103- $ this ->assertTrue ($ this ->db ->transStatus ());
104-
105- // Duplicate entry '1' for key 'PRIMARY'
106- $ jobData = [
107- 'id ' => 1 ,
108- 'name ' => 'Comedian ' ,
109- 'description ' => 'Theres something in your teeth ' ,
110- ];
111- $ builder ->insert ($ jobData );
112-
113- $ this ->assertFalse ($ this ->db ->transStatus ());
114-
115- $ this ->db ->transComplete ();
116-
117- $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Grocery Sales ' ]);
118-
119- $ this ->enableDBDebug ();
120- }
121-
122- public function testTransStrictTrueAndDBDebugFalse ()
123- {
124- $ this ->disableDBDebug ();
125-
126118 $ builder = $ this ->db ->table ('job ' );
127119
128120 // The first transaction group
@@ -164,14 +156,10 @@ public function testTransStrictTrueAndDBDebugFalse()
164156 $ this ->db ->transComplete ();
165157
166158 $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Comedian ' ]);
167-
168- $ this ->enableDBDebug ();
169159 }
170160
171- public function testTransStrictFalseAndDBDebugFalse ()
161+ public function testTransStrictFalse ()
172162 {
173- $ this ->disableDBDebug ();
174-
175163 $ builder = $ this ->db ->table ('job ' );
176164
177165 $ this ->db ->transStrict (false );
@@ -215,7 +203,5 @@ public function testTransStrictFalseAndDBDebugFalse()
215203 $ this ->db ->transComplete ();
216204
217205 $ this ->seeInDatabase ('job ' , ['name ' => 'Comedian ' ]);
218-
219- $ this ->enableDBDebug ();
220206 }
221207}
0 commit comments