This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,11 @@ public function key()
194
194
*/
195
195
public function current ()
196
196
{
197
+ if (-1 === $ this ->buffer ) {
198
+ // datasource was an array when the resultset was initialized
199
+ return $ this ->dataSource ->current ();
200
+ }
201
+
197
202
if ($ this ->buffer === null ) {
198
203
$ this ->buffer = -2 ; // implicitly disable buffering from here on
199
204
} elseif (is_array ($ this ->buffer ) && isset ($ this ->buffer [$ this ->position ])) {
Original file line number Diff line number Diff line change @@ -89,6 +89,20 @@ public function testCanProvideIteratorAsDataSource()
89
89
self ::assertSame ($ it , $ this ->resultSet ->getDataSource ());
90
90
}
91
91
92
+ public function testCanProvideArrayAsDataSource ()
93
+ {
94
+ $ dataSource = [['foo ' ]];
95
+ $ this ->resultSet ->initialize ($ dataSource );
96
+ $ this ->assertEquals ($ dataSource [0 ], (array ) $ this ->resultSet ->current ());
97
+
98
+ $ returnType = new ReturnType ();
99
+ $ dataSource = [$ returnType ];
100
+ $ this ->resultSet ->setArrayObjectPrototype ($ returnType );
101
+ $ this ->resultSet ->initialize ($ dataSource );
102
+ $ this ->assertEquals ($ dataSource [0 ], $ this ->resultSet ->current ());
103
+ $ this ->assertContains ($ dataSource [0 ], $ this ->resultSet );
104
+ }
105
+
92
106
public function testCanProvideIteratorAggregateAsDataSource ()
93
107
{
94
108
$ iteratorAggregate = $ this ->getMockBuilder ('IteratorAggregate ' )
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ namespace ZendTest \Db \ResultSet ;
5
+
6
+
7
+ class ReturnType
8
+ {
9
+ public function exchangeArray (array $ values )
10
+ {
11
+
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments