我在这个文件中的ryapi文件夹connection.php中创建了一个文件我推出了这段代码:
<?php
require_once 'PHPUnit/Framework.php';
class DataTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider provider
*/
public function testAdd($a, $b, $c)
{
$this->assertEquals($c, $a + $b);
}
public function provider()
{
return array(
array(0, 0, 0),
array(0, 1, 1),
array(1, 0, 1),
array(1, 1, 3)
);
}
}
?>
当我按照以下错误运行此测试时:
ubuntu@ip-10-162-234-205:/var/www/ryapi$ phpunit DataTest
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
PHPUnit 3.4.5 by Sebastian Bergmann.
Argument #1 of PHPUnit_Util_Fileloader:checkAndLoad() is no existing fileubuntu@ip-10-162-234-205:/var/www/ryapi$
请建议怎么做? 谢谢 的修改 运行命令pear install --alldeps --force phpunit / PHPUnit
ubuntu@ip-10-162-234-205:/var/www/ryapi$ sudo pear install --alldeps --force phpunit/PHPUnit
warning: phpunit/PHPUnit requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
phpunit/PHPUnit can optionally use PHP extension "dbus"
warning: phpunit/DbUnit requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
warning: phpunit/File_Iterator requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
warning: phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
warning: phpunit/PHPUnit_MockObject requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
warning: phpunit/PHPUnit_Selenium requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
warning: phpunit/PHP_TokenStream requires PEAR Installer (version >= 1.9.1), installed version is 1.9.0
downloading PHPUnit-3.5.11.tgz ...
Starting to download PHPUnit-3.5.11.tgz (117,869 bytes)
..........................done: 117,869 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/PHPUnit" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/PHPUnit"
downloading DbUnit-1.0.1.tgz ...
Starting to download DbUnit-1.0.1.tgz (39,055 bytes)
...done: 39,055 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/DbUnit" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/DbUnit"
downloading File_Iterator-1.2.3.tgz ...
Starting to download File_Iterator-1.2.3.tgz (3,406 bytes)
...done: 3,406 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/File_Iterator" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/File_Iterator"
downloading PHP_CodeCoverage-1.0.4.tgz ...
Starting to download PHP_CodeCoverage-1.0.4.tgz (115,029 bytes)
...done: 115,029 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/PHP_CodeCoverage" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/PHP_CodeCoverage"
downloading PHPUnit_MockObject-1.0.8.tgz ...
Starting to download PHPUnit_MockObject-1.0.8.tgz (18,199 bytes)
...done: 18,199 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/PHPUnit_MockObject" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/PHPUnit_MockObject"
downloading PHPUnit_Selenium-1.0.2.tgz ...
Starting to download PHPUnit_Selenium-1.0.2.tgz (16,412 bytes)
...done: 16,412 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/PHPUnit_Selenium" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/PHPUnit_Selenium"
downloading PHP_TokenStream-1.0.1.tgz ...
Starting to download PHP_TokenStream-1.0.1.tgz (7,250 bytes)
...done: 7,250 bytes
Validation Error: This package.xml requires PEAR version 1.9.1 to parse properly, we are version 1.9.0
Parsing of package.xml from file "/build/buildd/php5-5.3.2/pear-build-download/package.xml" failed
Download of "phpunit/PHP_TokenStream" succeeded, but it is not a valid package archive
Error: cannot download "phpunit/PHP_TokenStream"
Download failed
install failed
ubuntu@ip-10-162-234-205:/var/www/ryapi$
答案 0 :(得分:3)
修改您的/etc/php5/cli/conf.d/mcrypt.ini
并将第1行从“#”更改为“;”
这应该可以解决问题并摆脱弃用消息。
你正在使用一个非常旧版本的PHPUnit,我建议升级,如果它仍然无法编辑你的问题,我会回复你。
pear install --alldeps --force phpunit/PHPUnit
pear upgrade pear/pear
并按照说明操作。或者只是pear upgrade pear
如果第一个没有成功(无论出于何种原因)