enableExceptions(true); $this->c = $c; } function tearDown() { try {$this->s->close();} catch(\Exception $e) {} $this->c->close(); unset($this->c); } protected function checkBinding($input, array $expectations) { $nativeStatement = $this->c->prepare("SELECT ? as value"); $s = new self::$imp($this->c, $nativeStatement); $types = array_unique(Statement::TYPES); foreach($types as $type) { $s->rebindArray([$type]); $val = $s->runArray([$input])->get()['value']; $this->assertSame($expectations[$type], $val, "Type $type failed comparison."); } } function testConstructStatement() { $nativeStatement = $this->c->prepare("SELECT ? as value"); $this->assertInstanceOf(Statement::class, new Db\SQLite3\Statement($this->c, $nativeStatement)); } function testBindMissingValue() { $nativeStatement = $this->c->prepare("SELECT ? as value"); $s = new self::$imp($this->c, $nativeStatement); $val = $s->runArray()->get()['value']; $this->assertSame(null, $val); } function testBindMultipleValues() { $exp = [ 'one' => 1, 'two' => 2, ]; $nativeStatement = $this->c->prepare("SELECT ? as one, ? as two"); $s = new self::$imp($this->c, $nativeStatement, ["int", "int"]); $val = $s->runArray([1,2])->get(); $this->assertSame($exp, $val); } function testBindWithoutType() { $this->assertException("paramTypeMissing", "Db"); $nativeStatement = $this->c->prepare("SELECT ? as value"); $s = new self::$imp($this->c, $nativeStatement, []); $val = $s->runArray([1])->get(); } }