testing zend with phpunit gives me "The mysql driver is not currently installed"
i have this testing class
<?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();
}
}
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
and i get this error
in application ini testing extends production so it should have all db config, what am i doing wrong ?
Most likely your php command line interpreter uses a different php.ini
file.
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
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,
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 uses the php.ini for Commandline. I think you have to enable the SQL Drivers there. You can check the path to your php.ini with (tested on OsX :-) )
php --ini
result:
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)
精彩评论