Browse Source

Code coverage fixes

microsub
J. King 5 years ago
parent
commit
527ecee393
  1. 2
      lib/Db/PDODriver.php
  2. 2
      lib/Db/PDOStatement.php
  3. 9
      lib/Db/PostgreSQL/PDOStatement.php
  4. 2
      tests/cases/Db/PostgreSQL/TestStatement.php

2
lib/Db/PDODriver.php

@ -28,9 +28,9 @@ trait PDODriver {
}
$changes = $r->rowCount();
try {
$lastId = 0;
$lastId = ($changes) ? $this->db->lastInsertId() : 0;
} catch (\PDOException $e) { // @codeCoverageIgnore
$lastId = 0;
}
return new PDOResult($r, [$changes, $lastId]);
}

2
lib/Db/PDOStatement.php

@ -42,9 +42,9 @@ class PDOStatement extends AbstractStatement {
}
$changes = $this->st->rowCount();
try {
$lastId = 0;
$lastId = ($changes) ? $this->db->lastInsertId() : 0;
} catch (\PDOException $e) { // @codeCoverageIgnore
$lastId = 0;
}
return new PDOResult($this->st, [$changes, $lastId]);
}

9
lib/Db/PostgreSQL/PDOStatement.php

@ -42,12 +42,13 @@ class PDOStatement extends \JKingWeb\Arsse\Db\AbstractStatement {
parent::retypeArray($bindings, $append);
$this->qMunged = self::mungeQuery($this->qOriginal, $this->types, false);
try {
// statement creation with PostgreSQL should never fail (it is not evaluated at creation time)
$s = $this->db->prepare($this->qMunged);
$this->st = new \JKingWeb\Arsse\Db\PDOStatement($this->db, $s, $this->bindings);
} catch (\PDOException $e) {
list($excClass, $excMsg, $excData) = $this->exceptionBuild(true);
throw new $excClass($excMsg, $excData);
} catch (\PDOException $e) { // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->exceptionBuild(true); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
}
$this->st = new \JKingWeb\Arsse\Db\PDOStatement($this->db, $s, $this->bindings);
}
return true;
}

2
tests/cases/Db/PostgreSQL/TestStatement.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\PostgreSQL;
/**
* @covers \JKingWeb\Arsse\Db\PDOStatement<extended>
* @covers \JKingWeb\Arsse\Db\PostgreSQL\PDOStatement<extended>
* @covers \JKingWeb\Arsse\Db\PDOError */
class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
protected static $implementation = "PDO PostgreSQL";

Loading…
Cancel
Save