We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 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->setControllerName('index');
$this->dispatcher->setActionName('someAction');
$this->dispatcher->setParams(array('a' => 'test1', 'b' => 'test2'));
$this->dispatcher->dispatch();
$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