Zend_Test:断言控制器失败 [英] Zend_Test: Assert Controller Failed

查看:31
本文介绍了Zend_Test:断言控制器失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Zend Framework 中使用 Zend_Test 进行单元测试.我已经正确配置了引导程序和测试环境,然后我从测试单元得到了这个错误输出

I use Zend_Test for unit testing in Zend Framework. I have configured the bootstrap and testing environment properly then I got this error output from test unit

Failed asserting last controller used <"error"> was "index"

当我在诸如

public function indexAction()
{
    $roleDb = new Model_DbTable_Role;
    $role = $roleDb->getAll();
    $this->_forward('login');
}

如果我删除两行角色,则单元测试成功.这是我的单元测试代码

If I remove two lines role, unit testing is success. It is my unit testing code

public function testIndexActionShouldRedirectToLoginAction()
{
    $this->dispatch('/index');
    $this->assertController('index');
    $this->assertAction('login');
}

这些线有什么问题?

我如何知道真正的错误,而不仅仅是断言上次使用的控制器失败<"error">?谢谢

How do I know the real error instead of just Failed asserting last controller used <"error">? Thank you

推荐答案

终于解决了.

这是因为 php 单元没有检测到 PDO pgsql.仅供参考,在 XAMPP 中有两个 php.ini 文件.

It was because of PDO pgsql was not detected by php unit. FYI, in XAMPP there are two files of php.ini.

首先,在 apache/bin 中,第二个在 php 文件夹中.XAMPP 总是将第一个 php.ini 用于 apache 服务器,但 php 单元使用第二个.我已经将第一个 php.ini 配置为使用 pgsql 但忘记了第二个.这就是为什么我的应用程序仍在运行但 php 单元不运行的原因.

First, inside apache/bin and second one is inside php folder. XAMPP always use the first php.ini for apache server but php unit use the second one. I have configured the first php.ini to use pgsql but forget the second one. It is the answer why my application still run but php unit doesn't.

然后,我在第二个 php.ini 中启用 pgsql 的扩展

Then, I enable extension for pgsql in the second php.ini

extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll
extension=php_pdo_pgsql.dll <= add it
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
extension=php_pdo_sqlite.dll
;extension=php_perl.dll
extension=php_pgsql.dll <= remove ';'

最后,感谢您对此问题的任何意见或建议.上帝保佑你们.:)

Last, thank you for any comments or suggestions for this problem. God bless you all. :)

这篇关于Zend_Test:断言控制器失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆