89125

Zend_Test on Action_Helper accessing $bootstrap->getOptions() error

Question:

I am accessing options from an action controller, which is working well with the application, but I've hit a problem when I attempt to UnitTest it:

PHP Fatal error: Call to a member function getOptions() on a non-object in /home/zendtest/library/ZC/Action/Helper/Signup.php on line 43

For my tests I followed the setup from ZC at http://www.zendcasts.com/unit-testing-action-helpers/2010/11/ with source available <a href="https://code.google.com/p/zendcasts/source/browse/trunk/zc65-unit-testing-action-helpers" rel="nofollow">here</a>

I added another test in tests/library/ZC/Action/Helper/SignupTest.php :

public function testMyTest() { $helper = new ZC_Action_Helper_Signup(); $this->dispatch('/'); $controller = new IndexController($this->getRequest(), $this->getResponse(), array()); $helper->setActionController($controller); $this->assertType('Zend_View',$helper->getConfig()); }

And I added the following function to /library/ZC/Action/Helper/Signup.php :

protected $_config; public function getConfig() { if (null == $this->_config) { $action = $this->getActionController(); $bootstrap = $action->getInvokeArg('bootstrap'); $config = $bootstrap->getOptions(); $this->_config = new Zend_Config($config); } return $this->_config; }

How can I properly test this action helper function?

Answer1:

Apparently, this is a known bug in the Zend Framework: <a href="http://framework.zend.com/issues/browse/ZF-8193?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel" rel="nofollow">http://framework.zend.com/issues/browse/ZF-8193?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel</a>

Recommend

  • Is the length of a DER-encoded RSAPublicKey (PKCS #1) for a 1024-bit RSA key pair consistent?
  • ms vc++ compiler optimizating away erroneous code
  • Timthumb htaccess rewrite
  • Uploading a zip file using POST in Javascript fails silently
  • How to check dictionary value is empty or not
  • csrf-token POST 405 (Method Not Allowed) Laravel
  • Prevent ASP.NET textbox within a form from submitting the form
  • CodeIgniter - Autoload
  • Cakephp Form Helper
  • Authentication - JavaScript - Logout issue
  • Are there algorithms for putting a digest into the file being digested?
  • Play Framework nested form errors missing
  • Prevent page break in text block with iText, XMLWorker
  • Python 3.2.2, error(scripts to exe)
  • NSIS decompiler
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • Git describe fails to return most recent annotated tag
  • Implementing “partial void” in VB
  • Sending HTML Form Data to Spring REST Web Service
  • Problem while Building a Setup Project for a windows Service?
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Combining SpatialPolygonsDataFrame of two neighbour countries
  • Asynchronous UI Testing in Xcode With Swift
  • Using $this when not in object context
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • angularjs unit test when to use $rootScope.$new()
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Perl system calls when running as another user using sudo
  • what is the difference between the asp.net mvc application and asp.net web application
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • Why winpcap requires both .lib and .dll to run?
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • A cron job substitute?
  • json Serialization in asp
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • reshape alternating columns in less time and using less memory