2
最近我使用了一個來源https://github.com/fmalk/codeigniter-phpunit
將PHPUnit測試集成到CodeIgniter的技巧。我已經完成了所有的操作,但是當我開始運行測試時,它給了我一個錯誤Unable to connect to the database server using the provided settings.
在database.php中,所有設置都是正確的,因爲它們都是相同的,所以測試和默認都是正確的。我可以通過localhost運行我的項目,它工作正常。 這是我的設置:PHPUnit無法連接到CodeIgniter數據庫並提供了設置
$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;