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

Issue Type: Bug Created: 2010-03-23T11:47:21.000+0000 Last Updated: 2012-11-20T21:38:14.000+0000 Status: Open Fix version(s): Reporter: Thomas Bachmann (thobach) Assignee: None Tags: - Zend_Controller

  • Zend_Test_PHPUnit

Related issues: Attachments:


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

<pre class="highlight">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:

<pre class="highlight">
$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:

<pre class="highlight">
$dojoHelper = $this->_helper->autoCompleteDojo;
$dojoHelper->suppressExit = true;

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


No comments to display

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.