I can’t solve it.
$this->_request->setBasePath('http://localhost/');
$this->_request->setModuleKey('admin');
$this->_request->setControllerKey('controller-page');
$this->_request->setActionKey('index');
$this->_sslRedirect->preDispatch($this->_request);
$this->assertRedirectRegex('/https:/');
In my controller plugin, preDispatch () may or may not redirect to SSL. This works in the browser, however I cannot write a test for it. The test does not work, for example:
Failed asserting response redirects to URL MATCHING "/https:/"
/srv/app/zend/library/Zend/Test/PHPUnit/Constraint/Redirect.php:190
/srv/app/zend/library/Zend/Test/PHPUnit/ControllerTestCase.php:764
/srv/app/www/tests/lib/Saffron/Controller/Plugin/SslRedirectTest.php:36
/usr/bin/phpunit:46
I also tried using $ this-> dispatch () inside Zend_Test_PHPUnit_ControllerTestCase right after the preDispatch () line, but for some reason this caused a 404 Not Found error ...
Any ideas?
olive source
share