public function pipeShouldPipeDataIntoTheRequestBody() { $requestData = new RequestData('POST', 'http://www.example.com'); $request = new Request($this->connector, $requestData); $this->successfulConnectionMock(); $this->stream->expects($this->at(4))->method('write')->with($this->matchesRegularExpression("#^POST / HTTP/1\\.0\r\nHost: www.example.com\r\nUser-Agent:.*\r\n\r\n\$#")); $this->stream->expects($this->at(5))->method('write')->with($this->identicalTo("some")); $this->stream->expects($this->at(6))->method('write')->with($this->identicalTo("post")); $this->stream->expects($this->at(7))->method('write')->with($this->identicalTo("data")); $factory = $this->createCallableMock(); $factory->expects($this->once())->method('__invoke')->will($this->returnValue($this->response)); $loop = $this->getMock('React\\EventLoop\\LoopInterface'); $request->setResponseFactory($factory); $stream = fopen('php://memory', 'r+'); $stream = new Stream($stream, $loop); $stream->pipe($request); $stream->emit('data', array('some')); $stream->emit('data', array('post')); $stream->emit('data', array('data')); $request->handleData("HTTP/1.0 200 OK\r\n"); $request->handleData("Content-Type: text/plain\r\n"); $request->handleData("\r\nbody"); }