示例#1
0
 public function testReadData_picksUpWhereReadLineLeftOff()
 {
     $expectedLine = 'this is a test' . Server::EOL;
     $expectedData = str_repeat('randomdata', 200) . Server::EOL;
     $partOne = substr($expectedLine . $expectedData, 0, Socket::MAX_SINGLE_RESPONSE_LENGTH);
     $partTwo = substr($expectedLine . $expectedData, Socket::MAX_SINGLE_RESPONSE_LENGTH);
     $this->_socketCreateSuccess();
     $this->_socketConnectSuccess();
     $this->_getNativeFunctionMock()->expects($this->exactly(2))->method('socket_read')->withConsecutive([$this->anything(), Socket::MAX_SINGLE_RESPONSE_LENGTH], [$this->anything(), strlen($partTwo)])->willReturnOnConsecutiveCalls($partOne, $partTwo);
     $socket = new Socket();
     $socket->connect();
     $actualLine = $socket->readLine();
     $actualData = $socket->readData(strlen($expectedData));
     $this->assertEquals($expectedLine, $actualLine);
     $this->assertEquals($expectedData, $actualData);
 }