我希望在表单验证(http://netefx.de/module/netefxvalidator/)的Silverstripe模块NetefxValidator中运行测试。我已经安装了一个新版本的Silverstripe CMS与此模块。我打开浏览器localhost:8888/dev/ tests /,可以看到所有Silverstripe的测试和NetefxValidator的测试。当我点击任何测试时,我会收到php警告和致命错误(示例如下)。有什么想法吗?
11-Jul-2014 06:52:52太平洋/奥克兰PHP警告: require_once(phpunit/scr/Framework/TestResult.php):无法打开流:在/Users/Base/Documents/WebDesigner第2行11-Jul-2014 06:52:52太平洋/奥克兰PHP致命错误: require_once():无法打开所需的‘phpunit/scr/ Design/NetefxValidator/framework/dev/SapphireTestReporter.php /TestResult.php’(include_path='/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/php-text-template:/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/phpunit-mock-objects:/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/php-token-stream:/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/php-file-iterator:/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/php-code-coverage:/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/php-timer:/Users/Base/Documents/Web Design/NetefxValidator/vendor/phpunit/phpunit:/Users/Base/Documents/Web Design/NetefxValidator/vendor/symfony/yaml:.:/Users/Base/Documents/Web Design/NetefxValidator/framework:/Users/Base/Documents/Web Design/NetefxValidator/framework/parsers:/Users/Base/Documents/Web Design/NetefxValidator/framework/thirdparty:.:/Applications/MAMP/bin/php/php5.5.10/lib/php') /Users/Base/Documents/Web Design/NetefxValidator/framework/dev/SapphireTestReporter.php第2行11-Jul-2014 06:52:52太平洋/奥克兰PHP警告:不能设置Cookie 'alternativeDatabaseName‘。该网站开始在/Users/Base/Documents/Web中/Users/Base/Documents/Web中的第101行输出内容,第117行11-Jul-2014 06:52:52太平洋/奥克兰Design/NetefxValidator/framework/dev/DebugView.php警告:不能设置Cookie 'alternativeDatabaseNameIv‘。站点开始输出/Users/Base/Documents/Web Design/NetefxValidator/framework/control/Cookie.php中/Users/Base/Documents/Web Design/NetefxValidator/framework/dev/DebugView.php中的第101行的内容,第117行
**我的设置:**遵循Silverstripe说明(http://docs.silverstripe.org/framework/en/topics/testing/),我已经通过Composer安装了PHPunit (composer update --dev),并且可以在Vendor文件夹中看到它。另外,我还成功地在终端中安装了PHPUnit。
下一步配置需要项目根目录中的phpunit.xml文件。这是我在github (https://github.com/silverstripe/doc.silverstripe.org/blob/master/phpunit.xml.dist)上找到的起点。我已经将NetefxValidator添加到测试套件中:
<phpunit bootstrap="framework/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>netefxvalidator/code/tests</directory>
<directory>cms/tests</directory>
<directory>framework/tests</directory>
</testsuite>
<listeners>
<listener class="SS_TestListener" file="framework/dev/TestListener.php" />
</listeners>
<groups>
<exclude>
<group>sanitychecks</group>
</exclude>
</groups>
</phpunit>
如何在TestResult.php中加载SapphireTestReporter.php所需的PHPunit类?此外,我认为我需要授予PHPunit对MySQL数据库的访问权限。有什么建议吗?
提前谢谢。
发布于 2014-08-04 09:28:58
不确定它是否能解决此问题,但您是否已为本地站点设置了一个包含$_FILE_TO_URL_MAPPING条目的环境文件。我想知道这是不是它找不到phpunit路径的原因,更多信息请参见下面的链接。
http://doc.silverstripe.com/framework/en/topics/environment-management
发布于 2014-08-13 03:59:59
感谢@K Mayo的建议。我四处摸索,发现它是错误的PHPUnit
版本。Silverstripe 3.1.5
支持PHPUnit 3.7
,而不是4.2
。将向Silverstripe
文档提交拉取请求以进行澄清。
https://stackoverflow.com/questions/24691235
复制相似问题