@@ -131,25 +131,35 @@ public function test_read() {
131131
132132 $ Protocol = new RedisProtocol ($ ConnectionMock = $ this ->getConnectionMock ());
133133
134- $ ConnectionMock ->method ('readLine ' )->willReturn (
135- "*3 \r\n" , "$1 \r\n" , ":2 \r\n" , "$1 \r\n" ,
136- "+OK \r\n" ,
137- "+PING-PONG \r\n" ,
138- ":100 \r\n" ,
139- ":-42 \r\n" ,
140- ":-1 \r\n" ,
141- "*3 \r\n" , "$3 \r\n" , "$3 \r\n" , "$3 \r\n" ,
142- "*3 \r\n" , "$3 \r\n" , "$0 \r\n" , "$-1 \r\n" ,
143- "$6 \r\n" ,
144- '-ERR SomeError '
145- );
146-
147- $ ConnectionMock ->method ('read ' )->willReturn (
148- "1 \r\n" , "3 \r\n" ,
149- "SET \r\n" , "foo \r\n" , "bar \r\n" ,
150- "SET \r\n" , "\r\n" ,
151- "\r\n\xff\x0\r\n\r\n"
152- );
134+ $ ConnectionMock ->method ('readLine ' )->will ($ this ->returnCallback (
135+ function () {
136+ static $ return = [
137+ "*3 \r\n" , "$1 \r\n" , ":2 \r\n" , "$1 \r\n" ,
138+ "+OK \r\n" ,
139+ "+PING-PONG \r\n" ,
140+ ":100 \r\n" ,
141+ ":-42 \r\n" ,
142+ ":-1 \r\n" ,
143+ "*3 \r\n" , "$3 \r\n" , "$3 \r\n" , "$3 \r\n" ,
144+ "*3 \r\n" , "$3 \r\n" , "$0 \r\n" , "$-1 \r\n" ,
145+ "$6 \r\n" ,
146+ '-ERR SomeError '
147+ ];
148+ return array_shift ($ return );
149+ }
150+ ));
151+
152+ $ ConnectionMock ->method ('read ' )->will ($ this ->returnCallback (
153+ function () {
154+ static $ return = [
155+ "1 \r\n" , "3 \r\n" ,
156+ "SET \r\n" , "foo \r\n" , "bar \r\n" ,
157+ "SET \r\n" , "\r\n" ,
158+ "\r\n\xff\x0\r\n\r\n"
159+ ];
160+ return array_shift ($ return );
161+ }
162+ ));
153163
154164 $ this ->assertSame (['1 ' , 2 , '3 ' ], $ Method ->invoke ($ Protocol ));
155165 $ this ->assertSame (true , $ Method ->invoke ($ Protocol ));
0 commit comments