efecarranza
efecarranza

Reputation: 754

Zend Framework Call to undefined method Zend\Http\Request::getServer()

I have a controller, that when request is Post, it gets the request, and from there I get REMOTE_ADDR, and REQUEST_TIME. The code works just fine, I get that information that I need.

However, I am writing an integration test for the entire flow of my web app, and when I send the request, I get Call to undefined method Zend\Http\Request::getServer() when it gets to that point of my action in the controller.

$server = $this->getRequest()->getServer();
$remoteAddr = $server['REMOTE_ADDR'];
$timestamp = $server['REQUEST_TIME'];

When I do

$request = $this->getRequest();

and look at $request, it has method, uri, queryParams, postParams, fileParams, version, headers, metadata and content. postData has everything I'm sending via my test, but it crashes when it gets to the point of getting the server.

Any ideas?

Thank you.

Upvotes: 2

Views: 4117

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

The request class your application is using is Zend\Http\PhpEnvironment\Request, which extends Zend\Http\Request with some PHP-specific stuff like getServer(). Change your test to use that and it should work fine.

Upvotes: 4

Related Questions