Skip to content

Commit

Permalink
TestConnection: Mock essential methods
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nilmerg committed Dec 17, 2024
1 parent e80f1b7 commit 350928e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Test/TestConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,39 @@ public function __construct()
{
$this->adapter = new TestAdapter();
}

public function connect()
{

}

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)
{

}
};
}
}

0 comments on commit 350928e

Please sign in to comment.