开发者

Using Simpletest PHP "unit testing for PHP", getting error message "Deprecated: Assigning the return value of new by reference is deprecated "

I am new to using simpl开发者_StackOverflow社区etest: http://www.simpletest.org/ for PHP and am using PHP 5.2* on my server, when I try to set up an initial test script based on their demo, I get a page full of errors like the one below... I am not sure if this is something to do with simpletest not being compatible with PHP 5.* or what the issue is, any insight is appreciated.. it seems that I can still use the library as it returns what seems to be appropriate below the errors, but I would like to understand this so I can fix it.. thanks

Here is an example of the php code I am using to call a simpletest function

<?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'));
    }
}
?>

And the error I get:

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


"Deprecated" means that something old-fashion, that possibly won't be supported by future versions of php is done. It should not be harmful, but should be taken care of by simpletest developers. Did you download the latest version of simpletest? If you want to understand, take a look at unit_tester.php on lines 74 and 89.


Rather than switching all errors off, just switch off deprecation warnings. The alternative is to do a find-and-replace on all the simpletest files: find "&new" and replace with "new". new by reference (&new) was only deprecated in PHP5.3, so hopefully that'll be fixed in the next SimpleTest release.


Are you sure you're using 5.2, and not 5.3, when running the unit tests? I seem to remember seeing these errors with PEAR packages running under 5.3.


I also had this problem while going through the simpletest tutorial.

To make these messages go away, I changed the display_errors = On setting in my php.ini file to display_errors = Off.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜