Skip to content

Commit b1e028b

Browse files
committed
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.
1 parent e80f1b7 commit b1e028b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/Test/TestConnection.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,38 @@ public function __construct()
1313
{
1414
$this->adapter = new TestAdapter();
1515
}
16+
17+
public function connect()
18+
{
19+
return $this;
20+
}
21+
22+
public function beginTransaction()
23+
{
24+
throw new \LogicException('Transactions are not supported by the test connection');
25+
}
26+
27+
public function commitTransaction()
28+
{
29+
throw new \LogicException('Transactions are not supported by the test connection');
30+
}
31+
32+
public function rollbackTransaction()
33+
{
34+
throw new \LogicException('Transactions are not supported by the test connection');
35+
}
36+
37+
public function prepexec($stmt, $values = null)
38+
{
39+
return new class extends \PDOStatement {
40+
public function getIterator(): \Iterator
41+
{
42+
return new \ArrayIterator([]);
43+
}
44+
45+
public function setFetchMode($mode, ...$args)
46+
{
47+
}
48+
};
49+
}
1650
}

0 commit comments

Comments
 (0)