首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在web浏览器中运行Silverstripe测试时出现Php警告。"phpunit/scr/Framework/TestResult.php“打开失败

在web浏览器中运行Silverstripe测试时出现Php警告。"phpunit/scr/Framework/TestResult.php“打开失败
EN

Stack Overflow用户
提问于 2014-07-11 14:18:41
回答 2查看 795关注 0票数 1

我希望在表单验证(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添加到测试套件中:

代码语言:javascript
运行
复制
<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数据库的访问权限。有什么建议吗?

提前谢谢。

EN

回答 2

Stack Overflow用户

发布于 2014-08-04 09:28:58

不确定它是否能解决此问题,但您是否已为本地站点设置了一个包含$_FILE_TO_URL_MAPPING条目的环境文件。我想知道这是不是它找不到phpunit路径的原因,更多信息请参见下面的链接。

http://doc.silverstripe.com/framework/en/topics/environment-management

票数 0
EN

Stack Overflow用户

发布于 2014-08-13 03:59:59

感谢@K Mayo的建议。我四处摸索,发现它是错误的PHPUnit版本。Silverstripe 3.1.5支持PHPUnit 3.7,而不是4.2。将向Silverstripe文档提交拉取请求以进行澄清。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24691235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档