使用phpunit测试zend会给我“当前未安装mysql驱动程序". [英] testing zend with phpunit gives me "The mysql driver is not currently installed"

查看:110
本文介绍了使用phpunit测试zend会给我“当前未安装mysql驱动程序".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个测试班

<?php

class IndexControllerTest extends ControllerTestCase
{
....


    public function testValidLoginShouldGoToProfilePage()
    {
        $this->request->setMethod('POST')
              ->setPost(array(
                  'email' => 'capoarea',
                  'password' => '123456'
              ));
        $this->dispatch('/user/login');
        $this->assertRedirectTo('/index/index');

        $this->resetRequest()
             ->resetResponse();

        $this->request->setMethod('GET')
             ->setPost(array());
        $this->dispatch('/cliente/index');
        $this->assertRoute('default');
        $this->assertModule('default');
        $this->assertController('cliente');
        $this->assertAction('index');
        $this->assertNotRedirect();
    }

}

和此application.ini

and this application.ini

[production]
.....
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.db.params.charset = "utf8"
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "gestionale"
resources.db.isDefaultTableAdapter = true
autoloaderNamespaces[] = "Gestionale_";serve per caricare il plugin di sotto quando si usa anche ZFdebug
resources.frontController.plugins.acl = "Gestionale_Controller_Plugin_Acl"
resources.db.params.profiler = true


....
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

我收到此错误

在应用程序ini 测试中扩展了 production ,因此它应该具有所有数据库配置,我在做什么错了?

in application ini testing extends production so it should have all db config, what am i doing wrong ?

推荐答案

您的php命令行解释器很可能使用了不同的php.ini文件.

Most likely your php command line interpreter uses a different php.ini file.

要检查MySQL驱动程序,请打开一个新的shell提示符,然后运行php -m并检查是否已加载mysql扩展.

To check for MySQL driver open a new shell prompt and run php -m and check that mysql extensions are loaded.

> php -m | grep -i sql
mysql
mysqli
mysqlnd
pdo_mysql
pdo_sqlite
SQLite
sqlite3

要查看已加载了什么ini文件,请使用php命令的-i标志

To see what ini file is loaded use the -i flag of php command

> php -i | grep ini
Configuration File (php.ini) Path => /opt/local/etc/php5
Loaded Configuration File => /opt/local/etc/php5/php.ini
Scan this dir for additional .ini files => /opt/local/var/db/php5
Additional .ini files parsed => /opt/local/var/db/php5/apc.ini,

不知道Windows上是否有类似grep的命令来过滤输出,否则,您必须检查php -mphp -i的所有输出以收集所需的行或安装 windows grep 实用程序

Don't know if on windows there is a grep like command to filter the output, if not you have to examine all the output of both php -m and php -i to gather the required lines or install a windows grep utility

这篇关于使用phpunit测试zend会给我“当前未安装mysql驱动程序".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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