Skip to content

Commit a0765a3

Browse files
committed
test: fix test code
1 parent 95a845d commit a0765a3

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

tests/system/Database/Live/TransactionTest.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace CodeIgniter\Database\Live;
1313

14-
use CodeIgniter\Database\Exceptions\DatabaseException;
1514
use CodeIgniter\Test\CIUnitTestCase;
1615
use CodeIgniter\Test\DatabaseTestTrait;
1716
use Config\Database;
17+
use Exception;
1818
use 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

0 commit comments

Comments
 (0)