File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ final class BadQueryTest extends CIUnitTestCase
3131 public function testBadQueryDebugTrue ()
3232 {
3333 $ this ->enableDBDebug ();
34+
3435 // expect an exception, class and message varies by DBMS
3536 $ this ->expectException (Exception::class);
37+
3638 $ this ->db ->query ('SELECT * FROM table_does_not_exist ' );
3739
3840 // this code is never executed
@@ -42,8 +44,10 @@ public function testBadQueryDebugFalse()
4244 {
4345 // WARNING this value will persist! take care to roll it back.
4446 $ this ->disableDBDebug ();
47+
4548 // this throws an exception when DBDebug is true, but it'll return FALSE when DBDebug is false
4649 $ query = $ this ->db ->query ('SELECT * FROM table_does_not_exist ' );
50+
4751 $ this ->assertFalse ($ query );
4852
4953 $ this ->enableDBDebug ();
Original file line number Diff line number Diff line change @@ -28,21 +28,26 @@ final class DbDebugTest extends CIUnitTestCase
2828 public function testDBDebugTrue ()
2929 {
3030 $ this ->enableDBDebug ();
31+
3132 $ this ->expectException ('Exception ' );
33+
3234 $ this ->db ->simpleQuery ('SELECT * FROM db_error ' );
3335 }
3436
3537 public function testDBDebugFalse ()
3638 {
3739 // WARNING this value will persist! take care to roll it back.
3840 $ this ->disableDBDebug ();
41+
3942 $ result = $ this ->db ->simpleQuery ('SELECT * FROM db_error ' );
43+
4044 $ this ->assertFalse ($ result );
4145 }
4246
4347 protected function tearDown (): void
4448 {
4549 $ this ->enableDBDebug ();
50+
4651 parent ::tearDown ();
4752 }
4853}
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ public function testUtilsOptimizeTableFalseOptimizeDatabaseDebugTrue()
118118
119119 $ this ->expectException (DatabaseException::class);
120120 $ this ->expectExceptionMessage ('Unsupported feature of the database platform you are using. ' );
121+
121122 $ util ->optimizeDatabase ();
122123
123124 // this point in code execution will never be reached
Original file line number Diff line number Diff line change @@ -36,10 +36,13 @@ public function testDeleteFail(): void
3636 {
3737 // WARNING this value will persist! take care to roll it back.
3838 $ this ->disableDBDebug ();
39+
3940 $ this ->createModel (JobModel::class);
41+
4042 $ this ->seeInDatabase ('job ' , ['name ' => 'Developer ' ]);
4143
4244 $ result = $ this ->model ->where ('name123 ' , 'Developer ' )->delete ();
45+
4346 $ this ->assertFalse ($ result );
4447 $ this ->seeInDatabase ('job ' , ['name ' => 'Developer ' ]);
4548
@@ -73,10 +76,13 @@ public function testDeleteWithSoftDeleteFail(): void
7376 {
7477 // WARNING this value will persist! take care to roll it back.
7578 $ this ->disableDBDebug ();
79+
7680 $ this ->createModel (UserModel::class);
81+
7782 $ this ->seeInDatabase ('user ' , ['name ' => 'Derek Jones ' , 'deleted_at IS NULL ' => null ]);
7883
7984 $ result = $ this ->model ->where ('name123 ' , 'Derek Jones ' )->delete ();
85+
8086 $ this ->assertFalse ($ result );
8187 $ this ->seeInDatabase ('user ' , ['name ' => 'Derek Jones ' , 'deleted_at IS NULL ' => null ]);
8288
Original file line number Diff line number Diff line change @@ -148,12 +148,14 @@ public function testInsertResultFail(): void
148148 'name123 ' => 'Apprentice ' ,
149149 'description ' => 'That thing you do. ' ,
150150 ];
151-
152151 $ this ->createModel (JobModel::class);
152+
153153 $ result = $ this ->model ->protect (false )->insert ($ data , false );
154+
154155 $ this ->assertFalse ($ result );
155156
156157 $ lastInsertId = $ this ->model ->getInsertID ();
158+
157159 $ this ->assertSame (0 , $ lastInsertId );
158160 $ this ->dontSeeInDatabase ('job ' , ['id ' => $ lastInsertId ]);
159161
Original file line number Diff line number Diff line change @@ -63,8 +63,8 @@ public function testSaveNewRecordArrayFail(): void
6363 'name123 ' => 'Apprentice ' ,
6464 'description ' => 'That thing you do. ' ,
6565 ];
66-
6766 $ result = $ this ->model ->protect (false )->save ($ data );
67+
6868 $ this ->assertFalse ($ result );
6969 $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Apprentice ' ]);
7070
@@ -96,8 +96,8 @@ public function testSaveUpdateRecordArrayFail(): void
9696 'name123 ' => 'Apprentice ' ,
9797 'description ' => 'That thing you do. ' ,
9898 ];
99-
10099 $ result = $ this ->model ->protect (false )->save ($ data );
100+
101101 $ this ->assertFalse ($ result );
102102 $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Apprentice ' ]);
103103
Original file line number Diff line number Diff line change @@ -98,19 +98,20 @@ public function testUpdateResultFail(): void
9898 {
9999 // WARNING this value will persist! take care to roll it back.
100100 $ this ->disableDBDebug ();
101+ $ this ->createModel (UserModel::class);
101102
102103 $ data = [
103104 'name ' => 'Foo ' ,
104105 'email ' => 'foo@example.com ' ,
105106 'country ' => 'US ' ,
106107 'deleted ' => 0 ,
107108 ];
108-
109- $ this ->createModel (UserModel::class);
110109 $ this ->model ->insert ($ data );
111110
112111 $ this ->setPrivateProperty ($ this ->model , 'allowedFields ' , ['name123 ' ]);
112+
113113 $ result = $ this ->model ->update (1 , ['name123 ' => 'Foo Bar 1 ' ]);
114+
114115 $ this ->assertFalse ($ result );
115116 $ this ->dontSeeInDatabase ('user ' , ['id ' => 1 , 'name ' => 'Foo Bar 1 ' ]);
116117
You can’t perform that action at this time.
0 commit comments