【问题标题】:Yii Framework testing with PHPUnit and Selenium error/warning使用 PHPUnit 和 Selenium 进行 Yii 框架测试错误/警告
【发布时间】:2012-08-21 00:01:33
【问题描述】:

我正在使用这本书:“使用 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
  • 硒版本:2.25.0
  • Yii 版本:v1.1.12

(都是最新的稳定版本)

【问题讨论】:

    标签: php selenium yii tdd phpunit


    【解决方案1】:

    好的..我已经解决了。我只是回答我自己的问题,以防其他人遇到这个问题。

    解决方法如下。

    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)
    

    【讨论】:

      【解决方案2】:

      如果我的输出是:

      /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 未找到

      我有你提到的文件结构

      【讨论】:

        猜你喜欢
        • 2011-12-16
        • 2012-03-22
        • 2014-05-26
        • 2015-01-27
        • 2013-05-30
        • 2013-08-03
        • 2020-01-29
        • 2013-06-19
        • 1970-01-01
        相关资源
        最近更新 更多