globalsBackup causes: PDOException: You cannot serialize or unserialize PDO instances。
在PHPUnit/Frameword/TestCase.php文件中,有一行protected $backupGlobals = TRUE;
把backupGlobals 改為false即可解決這個問題。不過從PHPUNIT開發小組成員的建議來看,他們是不支持用修改backupGlobals的值來解決這個問題的。
The majority of users of PHPUnit expects it to work as it does when the backup of $GLOBALSfeature is enabled. This is why it is enabled by default.
If your tests exercise code that puts unserializable objects into $GLOBALS you can disable the feature.
From a software design perspective, you should not have a global instance of PDO to begin with.
所以更好的解決方法就是在:
$db = SmartPHP_Db::factory($dbConfig);
SmartPHP_Pool::set("db" , $db);
SmartPHP_Db_Table::setDefaultAdapter($db);
這段代碼之后,再添加一句:
unset($db);
這樣子就完美解決了You cannot serialize or unserialize PDO instances這個問題。
新聞熱點
疑難解答