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

Code coverage fixes

This commit is contained in:
J. King 2018-11-29 13:56:15 -05:00
parent 4a1c23ba45
commit 527ecee393
4 changed files with 8 additions and 7 deletions

View file

@ -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]);
} }

View file

@ -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]);
} }

View file

@ -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;
} }

View file

@ -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";