public function testSendAsyncAndCompleteRequestWithStream() { $ping = new Request('/ping'); $ping->setArgument('address', HOSTNAME)->setArgument('interval', '0.5')->setTag('ping'); $repliesCount = 0; $this->object->sendAsync($ping, function ($response, $client) use(&$repliesCount) { PHPUnit_Framework_TestCase::assertInstanceOf(ROS_NAMESPACE . '\\Response', $response, 'A callback must receive a single response per call'); PHPUnit_Framework_TestCase::assertInstanceOf(ROS_NAMESPACE . '\\Client', $client, 'A callback must receive a copy of the client object'); PHPUnit_Framework_TestCase::assertEquals('ping', $response->getTag(), 'The callback must only receive responses meant for it.'); $repliesCount++; }); sleep(1); $arpPrint = new Request('/ip/arp/print'); $arpPrint->setTag('arp'); $this->object->sendAsync($arpPrint); $this->assertFalse($this->object->isStreamingResponses()); $this->assertFalse($this->object->setStreamingResponses(true)); $this->assertTrue($this->object->isStreamingResponses()); $list = $this->object->completeRequest('arp'); $this->assertInstanceOf(ROS_NAMESPACE . '\\ResponseCollection', $list, 'The list is not a collection'); $this->assertGreaterThan(0, $repliesCount, "No responses for '" . HOSTNAME . "' before of 'arp' is done."); $this->assertInternalType('resource', $list[0]->getProperty('address'), 'The address is not a stream'); }