安装 PEAR 并按照 http://www.phpunit.de/manual/current/en/installation.html 上的说明进行操作:
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit.
然后,我创建了测试:
<?php
# error reporting
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
# include TestRunner
require_once 'PHPUnit/TextUI/TestRunner.php';
# our test class
class ExampleTest extends PHPUnit_Framework_TestCase
{
public function testOne()
{
$this->assertTrue(FALSE);
}
}
# run the test
$suite = new PHPUnit_Framework_TestSuite('ExampleTest');
PHPUnit_TextUI_TestRunner::run($suite);
?>
我在 php.ini 文件中包含了以下内容并重新启动了 Apache:
include_path = ".;C:\Program Files/wamp/bin/php/php5.3.8"
include_path = ".;C:\Program Files/wamp/bin/php/php5.3.8/pear"
include_path = ".;C:\Program Files/wamp/bin/php/php5.3.8/pear/PHPUnit"
我得到 Warning: require_once(PHPUnit/TextUI/TestRunner.php) [function.require-once]: failed to open stream: No such file or directory in ...
为什么包含路径不起作用?是因为Program files
里面有空格吗?
在 Windows XP 和 WAMP 中工作。
编辑:我按照建议更新了路径。
在调用 require_once 之前 echo ini_get('include_path');
的输出是:
.;C:\Program Files/wamp/bin/php/php5.3.8/pear
此外,删除 require_once 命令会引发 Fatal error: Class 'PHPUnit_Framework_TestCase' not found in...
最佳答案
通过将这三行添加到 ini,最后一行将覆盖所有内容。只用这个
include_path = ".;C:\Program Files\wamp\bin\php\php5.3.8\pear"
编辑:添加@Gordon 评论。我们需要保留 \pear
。因为内部 pear 库假设 pear 已经在包含路径中。
http://pear.php.net/manual/en/installation.checking.php#installation.checking.cli.modifyingphpini
关于php - 设置包括 PEAR on Wamp 的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8112866/