ZF-9520: Zend_Controller_Action_Helper_AutoComplete_Abstract (Dojo / Scriptaculous) doesn't work with unit tests since "exit;" is called


When I call $this->_helper->autoCompleteDojo($matches) as stated in the documentation my PHPUnit tests crash without any response.

ThomasMBP:tests thobach$ /usr/local/zend/bin/phpunit
PHPUnit 3.4.11 by Sebastian Bergmann.

F...ThomasMBP:tests thobach$

The reason is that exit; is called in Zend_Controller_Action_Helper_AutoComplete_Abstract when $suppressExit == false.

The class Zend_Test_PHPUnit_ControllerTestCase already disables the exit statement (setExit(false), suppressExit) for: * $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); * $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');

But it is not done for all the other possible exits in Zend Framework: * Zend/OpenId.php * Zend/Controller/Action/Helper/AutoComplete/Abstract.php * Zend/ProgressBar/Adapter/JsPull.php * ZendX/Console/Process/Unix.php

When I try to overload the dispatch function in my abstract class ControllerTestCase (extends Zend_Test_PHPUnit_ControllerTestCase) and add the following:

$dojo = Zend_Controller_Action_HelperBroker::getStaticHelper('autoCompleteDojo');
$dojo->suppressExit = true;

nothing happens. Maybe autoCompleteDojo cannot be called via getStaticHelper.

So what I did was not using autoCompleteDojo as documented, but rather:

$dojoHelper = $this->_helper->autoCompleteDojo;
$dojoHelper->suppressExit = true;

If you have further questions, I am glad to help.


No comments to display