From 7f7d0cd1e7ee075a5f2c51e55fbf277f6e7fe54e Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 8 Mar 2017 13:59:20 -0500 Subject: [PATCH] All test for constraint violation exception --- tests/Db/SQLite3/TestDbStatementSQLite3.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Db/SQLite3/TestDbStatementSQLite3.php b/tests/Db/SQLite3/TestDbStatementSQLite3.php index ab05585..59b8cdb 100644 --- a/tests/Db/SQLite3/TestDbStatementSQLite3.php +++ b/tests/Db/SQLite3/TestDbStatementSQLite3.php @@ -58,9 +58,17 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase { } function testBindWithoutType() { - $this->assertException("paramTypeMissing", "Db"); - $nativeStatement = $this->c->prepare("SELECT ? as value"); + $nativeStatement = $this->c->prepare("SELECT ? as value"); + $this->assertException("paramTypeMissing", "Db"); $s = new self::$imp($this->c, $nativeStatement, []); - $val = $s->runArray([1])->get(); + $s->runArray([1])->get(); } + + function testViolateConstraint() { + $this->c->exec("CREATE TABLE test(id integer not null)"); + $nativeStatement = $this->c->prepare("INSERT INTO test(id) values(?)"); + $s = new self::$imp($this->c, $nativeStatement, ["int"]); + $this->assertException("constraintViolation", "Db", "ExceptionInput"); + $s->runArray([null])->get(); + } } \ No newline at end of file