1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Add tests for type mismatches

This commit is contained in:
J. King 2017-03-09 09:44:50 -05:00
parent 95ee51563d
commit f0adf08b1e
2 changed files with 20 additions and 0 deletions

View file

@ -49,6 +49,12 @@ class TestDbDriverSQLite3 extends \PHPUnit\Framework\TestCase {
$this->drv->exec("INSERT INTO test(id) values(null)");
}
function testExecTypeViolation() {
$this->drv->exec("CREATE TABLE test(id integer primary key)");
$this->assertException("typeViolation", "Db", "ExceptionInput");
$this->drv->exec("INSERT INTO test(id) values('ook')");
}
function testValidQuery() {
$this->assertInstanceOf(Db\SQLite3\Result::class, $this->drv->query("SELECT 1"));
}
@ -70,4 +76,10 @@ class TestDbDriverSQLite3 extends \PHPUnit\Framework\TestCase {
$this->assertException("constraintViolation", "Db", "ExceptionInput");
$this->drv->query("INSERT INTO test(id) values(null)");
}
function testQueryTypeViolation() {
$this->drv->exec("CREATE TABLE test(id integer primary key)");
$this->assertException("typeViolation", "Db", "ExceptionInput");
$this->drv->query("INSERT INTO test(id) values('ook')");
}
}

View file

@ -71,4 +71,12 @@ class TestDbStatementSQLite3 extends \PHPUnit\Framework\TestCase {
$this->assertException("constraintViolation", "Db", "ExceptionInput");
$s->runArray([null]);
}
function testMismatchTypes() {
$this->c->exec("CREATE TABLE test(id integer primary key)");
$nativeStatement = $this->c->prepare("INSERT INTO test(id) values(?)");
$s = new self::$imp($this->c, $nativeStatement, ["str"]);
$this->assertException("typeViolation", "Db", "ExceptionInput");
$s->runArray(['ook']);
}
}