2012-08-25 71 views
3

我正在使用本書:「使用Yii 1.1和PHP5進行敏捷Web應用程序開發」開始使用Yii。Yii使用PHPUnit和Selenium進行框架測試錯誤/警告

在建立我的TDD環境和運行我的第一次測試,以下警告彈出:

[email protected]:/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
  • 硒版本:2.25.0
  • Yii版本:v1.1.12

(都是最新的穩定版本)

回答

6

好的..我解決了它。我只是回答我自己的問題,以防其他人遇到這個問題。

解決方法如下。

更改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); 
    } 
} 

你的輸出將是:

[email protected]:/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) 
-1

什麼,如果我的輸出是:

/usr/local/bin/phpunit: line 1: html: No such file or directory /usr/local/bin/phpunit: line 2: syntax error near unexpected token <' 'usr/local/bin/phpunit: line 2: 404未找到

我有我的文件結構,正如你所提到