PHPUnit:无法断言最后使用的控制器<“错误”>

发布于 2024-09-16 08:40:40 字数 1749 浏览 2 评论 0 原文

我正在本地服务器(ubuntu 10.04 LTS Lucid Lynx)上开发一个使用 postgre 数据库的 ZF 项目。
我正在尝试使用 phpunit 运行一个非常简单的测试:

    public function testIndexAction() {
        $this->dispatch('/');  
        $this->assertController('index');  
        $this->assertAction('index');  
        $this->assertModule('default');  
        $this->assertXpathContentContains('/html/body/div[1]/div[@id=\'content\']/p', 'Los puntos de mis amigos son mis amigos..');  
    }

但它在第一个断言上失败并显示以下消息:

Failedassertinglastcontrollerused<"error">是“索引”
I found this question where the author had the same problem: he solved it by adding to his 2nd php.ini the php_pdo_pgsql.dll library. But he's on windows and using xampp.
Anyway I checked it: the /etc/php5/apache2/php.ini has those 3 lines:
extension=msql.so
extension=pgsql.so
extension=pdo_pgsql.so
and I added them in the other php.ini file I found: /etc/php5/cli/php.ini and now when I run the test it says:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/msql.so' - /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_pgsql.so' - /usr/lib/php5/20090626+lfs/pdo_pgsql.so: undefined symbol: php_pdo_register_driver in Unknown on line 0
PHP Warning:  Module 'pgsql' already loaded in Unknown on line 0
and now I''m really out of ideas...
Can anyone point me in the right direction?
thanx

I am working on a ZF project wich use a postgre database, on my local server (ubuntu 10.04 LTS Lucid Lynx).
I'm trying to run a very simple test with phpunit:

    public function testIndexAction() {
        $this->dispatch('/');  
        $this->assertController('index');  
        $this->assertAction('index');  
        $this->assertModule('default');  
        $this->assertXpathContentContains('/html/body/div[1]/div[@id=\'content\']/p', 'Los puntos de mis amigos son mis amigos..');  
    }

but it fails on the first assertion with this message:

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

I found this question where the author had the same problem: he solved it by adding to his 2nd php.ini the php_pdo_pgsql.dll library. But he's on windows and using xampp.
Anyway I checked it: the /etc/php5/apache2/php.ini has those 3 lines:

extension=msql.so
extension=pgsql.so
extension=pdo_pgsql.so

and I added them in the other php.ini file I found: /etc/php5/cli/php.ini and now when I run the test it says:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/msql.so' - /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_pgsql.so' - /usr/lib/php5/20090626+lfs/pdo_pgsql.so: undefined symbol: php_pdo_register_driver in Unknown on line 0
PHP Warning:  Module 'pgsql' already loaded in Unknown on line 0

and now I''m really out of ideas...
Can anyone point me in the right direction?
thanx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那请放手 2024-09-23 08:40:40

事实证明,我的测试数据库的一张表中缺少一列。我添加了它,现在好了。由于我花了最后几个小时试图让 phpunit 工作,所以我仍然在考虑一般配置,而不是我的代码。

It turned out that there was one column missing in one table of my test db. I added it and now it's fine. As I had spent the last few hours trying to get phpunit working I was still thinking about general configuration, not about my code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文