最近我使用源https://github.com/fmalk/codeigniter-phpunit
的技巧将PHPUnit测试集成到CodeIgniter。我已按指令完成所有操作,但当我开始运行测试时,它会给我一个错误Unable to connect to the database server using the provided settings.
在database.php中,所有设置都是正确的,对于测试和默认设置都是正确的,因为它们是相同的。我可以通过localhost运行我的项目,它工作正常。
这是我的设置:
$db['testing']['hostname'] = 'localhost';
$db['testing']['username'] = 'root';
$db['testing']['password'] = 'motngaycu';
$db['testing']['database'] = 'work_is_easy';
$db['testing']['dbdriver'] = 'mysql';
$db['testing']['dbprefix'] = '';
$db['testing']['pconnect'] = TRUE;
$db['testing']['db_debug'] = TRUE;
$db['testing']['cache_on'] = FALSE;
$db['testing']['cachedir'] = '';
$db['testing']['char_set'] = 'utf8';
$db['testing']['dbcollat'] = 'utf8_general_ci';
$db['testing']['swap_pre'] = '';
$db['testing']['autoinit'] = TRUE;
$db['testing']['stricton'] = FALSE;