-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTestConnection.php
More file actions
65 lines (55 loc) · 1.53 KB
/
TestConnection.php
File metadata and controls
65 lines (55 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace ipl\Sql\Test;
use ipl\Sql\Connection;
/**
* Config-less test connection
*/
class TestConnection extends Connection
{
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)
{
if (PHP_MAJOR_VERSION >= 8) {
return new class extends \PDOStatement {
public function getIterator(): \Iterator
{
return new \ArrayIterator([]);
}
public function setFetchMode($mode, ...$args): true
{
return true;
}
};
} else {
return new class extends \PDOStatement {
public function getIterator(): \Iterator
{
return new \ArrayIterator([]);
}
public function setFetchMode($mode, ...$params): true
{
return true;
}
};
}
}
}