Skip to content

Commit c07666d

Browse files
committed
Test Database::prepare method exceptions
1 parent 8fcef27 commit c07666d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/DatabaseTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,19 @@ public function testPrepare() : void
346346
PreparedStatement::class,
347347
static::$database->prepare('SELECT * FROM `t1` WHERE `c1` = ?')
348348
);
349+
$this->expectException(\mysqli_sql_exception::class);
350+
static::$database->prepare('FOO');
351+
}
352+
353+
/**
354+
* @runInSeparateProcess
355+
*/
356+
public function testPrepareRuntimeException() : void
357+
{
358+
\mysqli_report(\MYSQLI_REPORT_OFF);
359+
$this->expectException(\RuntimeException::class);
360+
$this->expectExceptionMessage('Prepared statement failed: FOO');
361+
static::$database->prepare('FOO');
349362
}
350363

351364
public function testInsertId() : void

0 commit comments

Comments
 (0)