File tree Expand file tree Collapse file tree 2 files changed +62
-10
lines changed
Expand file tree Collapse file tree 2 files changed +62
-10
lines changed Original file line number Diff line number Diff line change @@ -36,15 +36,30 @@ public function rollbackTransaction()
3636
3737 public function prepexec ($ stmt , $ values = null )
3838 {
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- };
39+ if (PHP_MAJOR_VERSION >= 8 ) {
40+ return new class extends \PDOStatement {
41+ public function getIterator (): \Iterator
42+ {
43+ return new \ArrayIterator ([]);
44+ }
45+
46+ public function setFetchMode ($ mode , ...$ args ): bool
47+ {
48+ return true ;
49+ }
50+ };
51+ } else {
52+ return new class extends \PDOStatement {
53+ public function getIterator (): \Iterator
54+ {
55+ return new \ArrayIterator ([]);
56+ }
57+
58+ public function setFetchMode ($ mode , $ params = null ): bool
59+ {
60+ return true ;
61+ }
62+ };
63+ }
4964 }
5065}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ipl \Tests \Sql ;
4+
5+ use ipl \Sql \Test \TestConnection ;
6+
7+ class TestConnectionTest extends \PHPUnit \Framework \TestCase
8+ {
9+ public function testPrepexec ()
10+ {
11+ $ connection = new TestConnection ();
12+ $ stmt = $ connection ->prepexec ('SELECT * FROM foo ' );
13+ $ this ->assertEmpty (iterator_to_array ($ stmt ));
14+ $ this ->assertTrue ($ stmt ->setFetchMode (\PDO ::FETCH_ASSOC ));
15+ }
16+
17+ public function testBeginTransaction ()
18+ {
19+ $ connection = new TestConnection ();
20+ $ this ->expectException (\LogicException::class);
21+ $ connection ->beginTransaction ();
22+ }
23+
24+ public function testCommitTransaction ()
25+ {
26+ $ connection = new TestConnection ();
27+ $ this ->expectException (\LogicException::class);
28+ $ connection ->commitTransaction ();
29+ }
30+
31+ public function testRollbackTransaction ()
32+ {
33+ $ connection = new TestConnection ();
34+ $ this ->expectException (\LogicException::class);
35+ $ connection ->rollbackTransaction ();
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments