PHPUnit测试的Yii默认项目配置问题


Yii default project configuration issue for PHPUnit tests

我有一个默认安装:

  • Xampp(Windows)
  • 激活curl扩展:(在C:''xamplep/php/php.ini中,扩展名=php_curl.dll)
  • Yii
  • Yii项目
  • PHPUnit(pear安装pear.PHPUnit.de/PHPUnit)
  • 硒(pear安装phpunit/phpunit_Senium)

一切都很顺利。所以我做了以下事情:

  1. 启动Apache/MMySQL
  2. 测试我的Yii项目是否显示:localhost/Yii
  3. 打开cmd>>cd C:''examplep''htdocs''yii''protected''tests
  4. >>phpunit functional/SiteTest.php

然后我得到这个输出:

PHPUnit 3.6.9 by Sebastian Bergmann.
Configuration read from C:'xampp'htdocs'yii'protected'tests'phpunit.xml
EEEEEE
Time: 25 seconds, Memory: 6.25Mb
There were 6 errors:
1) SiteTest::testIndex
RuntimeException: couldn't connect to host
C:'xampp'htdocs'yiiframework'test'CWebTestCase.php:63
C:'xampp'php'phpunit:46
2) SiteTest::testContact
RuntimeException: couldn't connect to host
C:'xampp'htdocs'yiiframework'test'CWebTestCase.php:63
C:'xampp'php'phpunit:46
3) SiteTest::testLoginLogout
RuntimeException: couldn't connect to host
C:'xampp'htdocs'yiiframework'test'CWebTestCase.php:63
C:'xampp'php'phpunit:46
4) SiteTest::testIndex
RuntimeException: couldn't connect to host
C:'xampp'htdocs'yiiframework'test'CWebTestCase.php:63
C:'xampp'php'phpunit:46
5) SiteTest::testContact
RuntimeException: couldn't connect to host
C:'xampp'htdocs'yiiframework'test'CWebTestCase.php:63
C:'xampp'php'phpunit:46
6) SiteTest::testLoginLogout
RuntimeException: couldn't connect to host
C:'xampp'htdocs'yiiframework'test'CWebTestCase.php:63
C:'xampp'php'phpunit:46
FAILURES!
Tests: 6, Assertions: 0, Errors: 6.

我已经研究过这个问题,似乎可能是一个cURL问题。因为这个错误对于PHPUnit是未知的,但是对于cURL是未知的。

发生了什么?我可以访问我的本地网站,而PHPUnit却不能?

编辑:我的php.ini:http://pastebin.com/9gPBNPmi

编辑2:

我可以回答我自己的问题。当你把问题打下来时,你会得到新的见解,这是很了不起的。

解决方案如下:

我下载了Selenium Server RC,并通过以下命令运行它:>>java-jar Selenium-Server.jar

然后,我使用以下命令再次测试了代码:>>phpunit functional/SiteTest.php它启动了Internet Explorer,但什么都没做,命令等待了很长时间,什么也没做。所以我不得不从C:''examplep''htdocs''yii''protected''tests''phpunit.xml:中删除这一行

<browser name="Internet Explorer" browser="*iexplore" />

所以它会运行Firefox而不是IE.

希望这能帮助到别人。