使用PHPUnit和Selenium错误/警告进行Yii Framework测试
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了使用PHPUnit和Selenium错误/警告进行Yii Framework测试,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2693字,纯文字阅读大概需要4分钟。
内容图文
我正在使用这本书:“使用Yii 1.1和PHP5进行敏捷Web应用程序开发”以开始使用Yii.
在设置我的TDD环境并运行我的第一个测试时,会弹出以下警告:
sl@cker:/var/www/demo/protected/tests$phpunit functional/SiteTest.php
PHPUnit 3.6.12 by Sebastian Bergmann.
Configuration read from /var/www/demo/protected/tests/phpunit.xml
PHP Warning: include(SiteTest: Firefox.php): failed to open stream: No such file or directory in /var/www/framework/YiiBase.php on line 423
PHP Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (include_path='.:/var/www/demo/protected/components:/var/www/demo/protected/models:/usr/share/php:/
usr/share/pear') in /var/www/framework/YiiBase.php on line 423
...PHP Warning: include(SiteTest: Firefox.php): failed to open stream: No such file or directory in /var/www/framework/YiiBase.php on line 423
PHP Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion (include_path='.:/var/www/demo/protected/components:/var/www/demo/protected/models:/usr/share/php:/
usr/share/pear') in /var/www/framework/YiiBase.php on line 423
Time: 44 seconds, Memory: 8.25Mb
OK (3 tests, 10 assertions)
有谁知道如何解决这个问题,还是我可以忽略这些警告?这本书没有说明一个名为Firefox.php的文件.测试确实在Firefox中运行.
额外信息:
> PHP版本5.3.10
>平台:Ubuntu 12.04
>服务器:Apache / 2.2.22
> PHPUnit版本:3.6.12
> Selenium版本:2.25.0
> Yii版本:v1.1.12
(都是最新的稳定版本)
解决方法:
好的..我已经解决了.我只是回答我自己的问题,以防其他人遇到这个问题.
解决方案如下.
将phpunit.xml更改为:
<phpunit bootstrap="bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<selenium>
<!-- <browser name="Firefox" browser="*firefox" /> -->
</selenium>
</phpunit>
并将WebTestCase.php更改为:
<?php
/**
* Change the following URL based on your server configuration
* Make sure the URL ends with a slash so that we can use relative URLs in test cases
*/
define('TEST_BASE_URL','http://localhost/demo/index-test.php/');
/**
* The base class for functional test cases.
* In this class, we set the base URL for the test application.
* We also provide some common methods to be used by concrete test classes.
*/
class WebTestCase extends CWebTestCase
{
/**
* Sets up before each test method runs.
* This mainly sets the base URL for the test application.
*/
protected function setUp()
{
parent::setUp();
$this->setBrowser('*firefox');
$this->setBrowserUrl(TEST_BASE_URL);
}
}
你的输出将是:
sl@cker:/var/www/demo/protected/tests$phpunit functional/SiteTest.php
PHPUnit 3.6.12 by Sebastian Bergmann.
Configuration read from /var/www/demo/protected/tests/phpunit.xml
...
Time: 32 seconds, Memory: 8.25Mb
OK (3 tests, 10 assertions)
内容总结
以上是互联网集市为您收集整理的使用PHPUnit和Selenium错误/警告进行Yii Framework测试全部内容,希望文章能够帮你解决使用PHPUnit和Selenium错误/警告进行Yii Framework测试所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。