We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Dispatcher setParams() not working in Unit Tests

Hi there,

in my unit test I'm trying to pass $_GET parameters to a controller action as follows:

$this->dispatcher->setParams(array('a' => 'test1', 'b' => 'test2'));
$view = $this->di->get('view');
$view->render('index', 'someAction');
$this->assertEquals($view->data['result'], 'success');

But the get params are not there in the controller. It just returns an empty array when I'm calling $this->request->getQuery(); in the controller. It works when I'm setting the $_GET variable directly.

Is there any other way to do this cleanly in a unit test?

umfortunatly, for now, only way is to set get superglobal manually