Getting a “No default module defined for this application” exception while running controller unit tests in zend framework

后端 未结 2 1058
南笙
南笙 2021-02-14 01:18

I have an application with the default directory structure, for an application without custom modules (see structure figure at the end).

I have written a ControllerTes

2条回答
  •  逝去的感伤
    2021-02-14 02:11

    This is a known bug.
    Here is my workaround to fix this issue:

    bootstrap = array($this, 'appBootstrap');
            parent::setUp();
        }
    
        public function appBootstrap()
        {
            $this->_application = new Zend_Application(APPLICATION_ENV,
                  APPLICATION_PATH . '/configs/application.ini'
            );
            $this->_application->bootstrap();
    
            /**
             * Fix for ZF-8193
             * http://framework.zend.com/issues/browse/ZF-8193
             * Zend_Controller_Action->getInvokeArg('bootstrap') doesn't work
             * under the unit testing environment.
             */
            $front = Zend_Controller_Front::getInstance();
            if($front->getParam('bootstrap') === null) {
                $front->setParam('bootstrap', $this->_application->getBootstrap());
            }
        }
    }
    

提交回复
热议问题