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

Test tweaks

This commit is contained in:
J. King 2018-12-21 17:51:49 -05:00
parent 5a133b795a
commit 206cca35a9
5 changed files with 12 additions and 9 deletions

View file

@ -37,7 +37,7 @@ trait PDOError {
case SQLite3::SQLITE_MISMATCH:
return [ExceptionInput::class, 'engineTypeViolation', $err[2]];
}
break;
break; // @codeCoverageIgnore
case "mysql":
switch ($err[1]) {
case 1205:
@ -47,7 +47,7 @@ trait PDOError {
case 1366:
return [ExceptionInput::class, 'engineTypeViolation', $err[2]];
}
break;
break; // @codeCoverageIgnore
}
return [Exception::class, "engineErrorGeneral", $err[0]."/".$err[1].": ".$err[2]]; // @codeCoverageIgnore
default:

View file

@ -30,11 +30,12 @@ class PDOStatement extends AbstractStatement {
protected function prepare(string $query): bool {
try {
// PDO statements aren't usually evaluated at creation, and so should not fail
$this->st = $this->db->prepare($query);
return true;
} catch (\PDOException $e) {
list($excClass, $excMsg, $excData) = $this->exceptionBuild();
throw new $excClass($excMsg, $excData);
} catch (\PDOException $e) { // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->exceptionBuild(); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
}
}

View file

@ -37,11 +37,12 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
protected function prepare(string $query): bool {
try {
// statements aren't evaluated at creation, and so should not fail
$this->st = $this->db->prepare($query);
return true;
} catch (\Exception $e) {
list($excClass, $excMsg, $excData) = $this->exceptionBuild();
throw new $excClass($excMsg, $excData);
} catch (\Exception $e) { // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->exceptionBuild(); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
}
}

View file

@ -95,6 +95,7 @@ abstract class BaseDriver extends \JKingWeb\Arsse\Test\AbstractTest {
public function testTranslateAToken() {
$this->assertRegExp("/^[a-z][a-z0-9]*$/i", $this->drv->sqlToken("greatest"));
$this->assertRegExp("/^\"?[a-z][a-z0-9_\-]*\"?$/i", $this->drv->sqlToken("nocase"));
$this->assertSame("distinct", $this->drv->sqlToken("distinct"));
}

View file

@ -8,7 +8,7 @@ namespace JKingWeb\Arsse\TestCase\Db\MySQLPDO;
/**
* @group slow
* @covers \JKingWeb\Arsse\Db\PDOStatement<extended>
* @covers \JKingWeb\Arsse\Db\MySQL\PDOStatement<extended>
* @covers \JKingWeb\Arsse\Db\PDOError */
class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
protected static $implementation = "PDO MySQL";