简体   繁体   中英

Why is “preDispatch” not being reached in my PhpUnit integration tests on Zend Framework controller?

I have an IndexContoller that extends MyCustom_Controller_Action, which extends Zend_Controller_Action.

I'm noticing that my integration tests (when I do $this->dispatch('/') ) never trigger the preDispatch methods of my IndexController, MyCustom_Controller_Action, or Zend_Controller_Action. However, the init() methods of those classes get reached.

How can I fix my testing setup so that the preDispatch functions get called, too (as in the normal flow on my production application)?

(They need to be called, or else I'm unable to test what actually is happening in the application.)

PHPUnit 3.5.15

Zend Framework 1.12

I was wrong. The preDispatch function was being reached.

I eventually proved that via Xdebug. I got Xdebug working with Netbeans and Phpunit. I found a super helpful personalized step-by-step generator. I created an anonymized copy of my php.ini and uploaded it to http://xdebug.org/wizard.php and followed the resulting steps, and now I can run something like the following via the Mac terminal:

php -dxdebug.remote_enable=1 -dxdebug.remote_host=127.0.0.1 -dxdebug.remote_autostart=On -dxdebug.remote_port=9001 -dxdebug.remote_mode=req /usr/local/opt/php55/bin/phpunit --filter testHeaderLocaleSwitchLoggedOut --bootstrap /code/master/tests/test.php --configuration /code/master/tests/phpunit.xml /code/master/tests/integration

Then Netbeans shows where the code stops at my break-points and lets me step through slowly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM