我有这个测试类
<?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
我收到此错误
在应用程序ini 测试扩展生产所以它应该有所有db配置,我做错了什么?
答案 0 :(得分: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 -m
和php -i
的所有输出以收集必填行或安装windows grep实用程序
答案 1 :(得分:2)
PHPUnit使用php.ini for Commandline。我认为你必须在那里启用SQL驱动程序。您可以使用(在OsX上测试:-))
检查php.ini的路径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)