2011-08-30 63 views
0

我有这个测试类使用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

[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 

和我得到这个错误enter image description here

in application ini testing extends production所以它应该有所有的db配置,我做错了什么?

回答

4

最有可能你的PHP命令行解释器使用不同php.ini文件。

要检查MySQL驱动程序是否打开新的shell提示符并运行php -m并检查是否加载了mysql扩展。

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

要查看的ini文件加载使用PHP命令-i标志

> 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实用程序

+0

我的php正在加载no .ini,因为EasyPhp都搞砸了,现在我修好了,非常感谢! – max4ever

2

PHPUnit使用php.ini作为命令行。我认为你必须在那里启用SQL驱动程序。您可以检查与路径到php.ini(在OSX :-)测试)

php --ini 

结果:

Configuration File (php.ini) Path: /Applications/MAMP/conf/php5.2 
Loaded Configuration File:   /Applications/MAMP/conf/php5.2/php.ini 
Scan for additional .ini files in: (none) 
Additional .ini files parsed:  (none) 
+0

对不起(至少在windows上)php -v类型的版本,php -m类型加载的模块 – max4ever

相关问题