/** * @covers ::__construct * @covers ::setStatement * @covers ::getStatement * @covers ::execute * * @throws ParserConfigurationException * @throws ParserRuntimeException */ public function testValidPrepare() { $this->adapterInstance->exec('CREATE TABLE IF NOT EXISTS dummy (foo INTEGER)'); $this->adapterInstance->exec('INSERT INTO dummy VALUES (123),(234),(345)'); $preparedStatement = $this->adapterInstance->prepare('SELECT COUNT(*) AS cnt FROM dummy WHERE foo >= :value'); $result = $preparedStatement->execute(['value' => 234]); $count = 0; if (array_key_exists(0, $result) && array_key_exists('cnt', $result[0])) { $count = (int) $result[0]['cnt']; } static::assertSame(2, $count); }
/** * @expectedException \Crossjoin\Browscap\Exception\ParserRuntimeException * * @covers ::prepare * * @throws ParserConfigurationException * @throws ParserRuntimeException */ public function testInvalidPrepare() { $this->adapterInstance->prepare('SELECT * FROM doesnotexist WHERE field = :value'); }