Browse Source

Code coverage fixes

microsub
J. King 6 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(); $changes = $r->rowCount();
try { try {
$lastId = 0;
$lastId = ($changes) ? $this->db->lastInsertId() : 0; $lastId = ($changes) ? $this->db->lastInsertId() : 0;
} catch (\PDOException $e) { // @codeCoverageIgnore } catch (\PDOException $e) { // @codeCoverageIgnore
$lastId = 0;
} }
return new PDOResult($r, [$changes, $lastId]); return new PDOResult($r, [$changes, $lastId]);
} }

2
lib/Db/PDOStatement.php

@ -42,9 +42,9 @@ class PDOStatement extends AbstractStatement {
} }
$changes = $this->st->rowCount(); $changes = $this->st->rowCount();
try { try {
$lastId = 0;
$lastId = ($changes) ? $this->db->lastInsertId() : 0; $lastId = ($changes) ? $this->db->lastInsertId() : 0;
} catch (\PDOException $e) { // @codeCoverageIgnore } catch (\PDOException $e) { // @codeCoverageIgnore
$lastId = 0;
} }
return new PDOResult($this->st, [$changes, $lastId]); 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); parent::retypeArray($bindings, $append);
$this->qMunged = self::mungeQuery($this->qOriginal, $this->types, false); $this->qMunged = self::mungeQuery($this->qOriginal, $this->types, false);
try { try {
// statement creation with PostgreSQL should never fail (it is not evaluated at creation time)
$s = $this->db->prepare($this->qMunged); $s = $this->db->prepare($this->qMunged);
$this->st = new \JKingWeb\Arsse\Db\PDOStatement($this->db, $s, $this->bindings); } catch (\PDOException $e) { // @codeCoverageIgnore
} catch (\PDOException $e) { list($excClass, $excMsg, $excData) = $this->exceptionBuild(true); // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->exceptionBuild(true); throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData);
} }
$this->st = new \JKingWeb\Arsse\Db\PDOStatement($this->db, $s, $this->bindings);
} }
return true; return true;
} }

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

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

Loading…
Cancel
Save