我對PHP使用simpletest:http://www.simpletest.org/不熟悉,並且在我的服務器上使用PHP 5.2 *當我嘗試根據他們的演示設置一個初始測試腳本時,我得到一個頁面充滿了如下所示的錯誤......我不確定這是否與簡單測試不兼容的PHP 5. *或什麼問題是,任何洞察力的讚賞..看來,我仍然可以使用庫,因爲它返回什麼似乎是適當的錯誤下面,但我想了解這個,所以我可以修復它..謝謝使用Simpletest PHP「對PHP進行單元測試」,得到錯誤消息「不贊成使用:通過引用指定新的返回值已被棄用」
這裏是我用來調用一個簡單測試函數的php代碼示例
<?php
require_once('C:/wamp/www/external/simpletest/simpletest/autorun.php');
class TestOfLogging extends UnitTestCase {
function testFirstLogMessagesCreatesFileIfNonexistent() {
@unlink(dirname(__FILE__) . '/../temp/test.log');
$log = new Log(dirname(__FILE__) . '/../temp/test.log');
$log->message('Should write this to a file');
$this->assertTrue(file_exists(dirname(__FILE__) . '/../temp/test.log'));
}
}
?>
和錯誤,我得到:
Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\external\simpletest\simpletest\unit_tester.php on line 74
Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\external\simpletest\simpletest\unit_tester.php on line 89
自從PHP 5.2發佈以來(不再需要使用'&new'(並且從早期版本開始,PHP 5.0就更普遍,但有一些問題)。針對這些事情獲取棄用警告是您看到可能受益於某些新語言功能的PHP 4代碼的一個標誌。禁用棄用警告會隱藏這些好處,因爲這是與測試相關的,所以也會隱藏測試系統的重要信息。 – hakre 2012-08-01 08:16:58