File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -239,4 +239,42 @@ public function testPurgeDeletedWithSoftDeleteFalse(): void
239
239
$ jobs = $ this ->model ->findAll ();
240
240
$ this ->assertCount (4 , $ jobs );
241
241
}
242
+
243
+ /**
244
+ * @dataProvider emptyPkValues
245
+ *
246
+ * @param int|string|null $id
247
+ */
248
+ public function testDeleteThrowDatabaseExceptionWithoutWhereClause ($ id ): void
249
+ {
250
+ // BaseBuilder throws Exception.
251
+ $ this ->expectException (DatabaseException::class);
252
+ $ this ->expectExceptionMessage (
253
+ 'Deletes are not allowed unless they contain a "where" or "like" clause. '
254
+ );
255
+
256
+ // $useSoftDeletes = false
257
+ $ this ->createModel (JobModel::class);
258
+
259
+ $ this ->model ->delete ($ id );
260
+ }
261
+
262
+ /**
263
+ * @dataProvider emptyPkValues
264
+ *
265
+ * @param int|string|null $id
266
+ */
267
+ public function testDeleteWithSoftDeleteThrowDatabaseExceptionWithoutWhereClause ($ id ): void
268
+ {
269
+ // Model throws Exception.
270
+ $ this ->expectException (DatabaseException::class);
271
+ $ this ->expectExceptionMessage (
272
+ 'Deletes are not allowed unless they contain a "where" or "like" clause. '
273
+ );
274
+
275
+ // $useSoftDeletes = true
276
+ $ this ->createModel (UserModel::class);
277
+
278
+ $ this ->model ->delete ($ id );
279
+ }
242
280
}
You can’t perform that action at this time.
0 commit comments