File tree Expand file tree Collapse file tree
tests/system/Database/Live Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212namespace CodeIgniter \Database \Live ;
1313
14- use CodeIgniter \Database \Exceptions \DatabaseException ;
1514use CodeIgniter \Test \CIUnitTestCase ;
1615use CodeIgniter \Test \DatabaseTestTrait ;
1716use Config \Database ;
17+ use Exception ;
1818use Tests \Support \Database \Seeds \CITestSeeder ;
1919
2020/**
@@ -78,11 +78,28 @@ public function testTransStartDBDebugTrue()
7878 $ builder ->insert ($ jobData );
7979
8080 $ this ->db ->transComplete ();
81- } catch (DatabaseException $ e ) {
81+ } catch (Exception $ e ) {
8282 // Do nothing.
83+
84+ // MySQLi
85+ // mysqli_sql_exception: Duplicate entry '1' for key 'PRIMARY'
86+
87+ // SQLite3
88+ // ErrorException: SQLite3::exec(): UNIQUE constraint failed: db_job.id
89+
90+ // Postgres
91+ // ErrorException: pg_query(): Query failed: ERROR: duplicate key value violates unique constraint "pk_db_job"
92+ // DETAIL: Key (id)=(1) already exists.
93+
94+ // SQLSRV
95+ // Exception: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot insert explicit
96+ // value for identity column in table 'db_job' when IDENTITY_INSERT is set to OFF.
97+
98+ // OCI8
99+ // ErrorException: oci_execute(): ORA-00001: unique constraint (ORACLE.pk_db_job) violated
83100 }
84101
85- $ this ->assertInstanceOf (DatabaseException ::class, $ e );
102+ $ this ->assertInstanceOf (Exception ::class, $ e );
86103 $ this ->dontSeeInDatabase ('job ' , ['name ' => 'Grocery Sales ' ]);
87104 }
88105
You can’t perform that action at this time.
0 commit comments