/** * Test's the init function of the http parser instance */ public function testInitFunction() { $parser = $this->parser; // build up request $parser->parseStartLine('GET / HTTP/1.1'); $parser->parseHeaderLine('Host: localhost'); // build up response $parser->getResponse()->setStatus(200); $parser->getResponse()->appendBodyStream('Hello World'); // get clean request and response objects $cleanRequest = new HttpRequest(); $cleanResponse = new HttpResponse(); // remove those resources to be able to compare them via php unit $cleanRequest->setBodyStream(null); $cleanResponse->setBodyStream(null); // finally init parser $parser->init(); // remove those resources to be able to compare them via php unit $parser->getRequest()->setBodyStream(null); $parser->getResponse()->setBodyStream(null); $this->assertEquals($cleanRequest, $parser->getRequest()); $this->assertEquals($cleanResponse, $parser->getResponse()); }