Skip to content

Commit 2b84d68

Browse files
committed
Added connection test for handle($data)
1 parent e9b7dd4 commit 2b84d68

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

lib/Wrench/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function handshake($data)
253253
* middle of a fragmented message.
254254
* @param string $data
255255
*/
256-
protected function handle($data)
256+
public function handle($data)
257257
{
258258
if (!$this->payload) {
259259
$this->payload = $this->protocol->getPayload();

lib/Wrench/Tests/ConnectionTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ public function testWrongPathHandshake($path, $request)
112112
$connection->handshake($request);
113113
}
114114

115+
/**
116+
* @dataProvider getValidHandleData
117+
*/
118+
public function testHandle($path, $request_handshake, array $requests)
119+
{
120+
$connection = $this->getConnectionForHandshake(
121+
$this->getConnectedSocket(),
122+
$path,
123+
$request_handshake
124+
);
125+
126+
$connection->handshake($request_handshake);
127+
128+
foreach ($requests as $request) {
129+
$connection->handle($request);
130+
}
131+
132+
return $connection;
133+
}
134+
115135
/**
116136
* @return Socket
117137
*/
@@ -163,6 +183,16 @@ protected function getConnectionForHandshake($socket, $path, $request)
163183
return $connection;
164184
}
165185

186+
protected function getConnectionForHandle($socket, $path, $request)
187+
{
188+
$connection = $this->getConnectionForHandshake($socket, $path, $request);
189+
190+
$valid = $this->getValidHandshakeData();
191+
192+
193+
return $connection;
194+
}
195+
166196
/**
167197
* @return ConnectionManager
168198
*/
@@ -239,6 +269,31 @@ public function getValidConstructorArguments()
239269
);
240270
}
241271

272+
/**
273+
* Data provider
274+
*/
275+
public function getValidHandleData()
276+
{
277+
$data = array();
278+
279+
$valid_requests = array(
280+
array('foobar'),
281+
array('foo', 'bar')
282+
);
283+
284+
$handshakes = $this->getValidHandshakeData();
285+
286+
foreach ($handshakes as $handshake) {
287+
foreach ($valid_requests as $requests) {
288+
$arguments = $handshake;
289+
$arguments[] = $requests;
290+
$data[] = $arguments;
291+
}
292+
}
293+
294+
return $data;
295+
}
296+
242297
/**
243298
* Data provider
244299
*/

0 commit comments

Comments
 (0)