From b1e028bb36d1880eca15acb18db506e555c6207f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 17 Dec 2024 15:33:26 +0100 Subject: [PATCH] TestConnection: Mock essential methods So that using it works somewhat. It is still not a mock that's configurable, i.e. it doesn't provide any results, but this is better than being fully unusable. --- src/Test/TestConnection.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Test/TestConnection.php b/src/Test/TestConnection.php index 981696b..bf03c12 100644 --- a/src/Test/TestConnection.php +++ b/src/Test/TestConnection.php @@ -13,4 +13,38 @@ public function __construct() { $this->adapter = new TestAdapter(); } + + public function connect() + { + return $this; + } + + public function beginTransaction() + { + throw new \LogicException('Transactions are not supported by the test connection'); + } + + public function commitTransaction() + { + throw new \LogicException('Transactions are not supported by the test connection'); + } + + public function rollbackTransaction() + { + throw new \LogicException('Transactions are not supported by the test connection'); + } + + public function prepexec($stmt, $values = null) + { + return new class extends \PDOStatement { + public function getIterator(): \Iterator + { + return new \ArrayIterator([]); + } + + public function setFetchMode($mode, ...$args) + { + } + }; + } }