简体   繁体   English

Selenium RC-无法重新声明类PHPUnit_Framework_TestCase

[英]Selenium RC - Cannot redeclare class PHPUnit_Framework_TestCase

This I have found on the net in various places but with no actual solution. 我在网上的很多地方都发现了这一点,但没有实际的解决方案。 The default code for running a test is 运行测试的默认代码是

<?php

set_include_path(get_include_path() . PATH_SEPARATOR . './PEAR/');
require_once 'Testing/Selenium.php';
require_once 'PHPUnit/Framework/TestCase.php';

class GoogleTest extends PHPUnit_Framework_TestCase
{
    private $selenium;

    public function setUp()
    {
        $this->selenium = new Testing_Selenium("*firefox", 
                                               "http://www.google.com");
        $this->selenium->start();
    }

    public function tearDown()
    {
        $this->selenium->stop();
    }

    public function testGoogle()
    {
        $this->selenium->open("/");
        $this->selenium->type("q", "hello world");
        $this->selenium->click("btnG");
        $this->selenium->waitForPageToLoad(10000);
        $this->assertRegExp("/Google Search/", $this->selenium->getTitle());
    }

}
?>

This gives me the following error 这给我以下错误

Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase in /usr/lib/php/PHPUnit/Framework/TestCase.php on line 115

My include path looks like this 我的包含路径如下所示

.:/usr/lib/php/ZendLatest/library/:/usr/lib/php/:./PEAR/

Can anyone help me fix this? 谁能帮我解决这个问题? It isn't obvious where the class is being re-declared, is it on line 115 of the file mentioned above or somewhere else? 重新声明该类的位置并不明显,是在上面提到的文件的第115行还是其他地方?

Thanks 谢谢

I have solved this by changing the line 我已经通过改变线解决了这个问题

 require_once 'PHPUnit/Framework/TestCase.php';

To

require_once 'PHPUnit/Framework.php';

The Framework.php file is the Bootstrap for PHPUnit and including this deals with all other includes. Framework.php文件是PHPUnit的引导程序,其中包括与所有其他包含项的交易。 Including TestCase.php doesn't work because that isn't the Bootstrap file and thus doesn't load PHPUnit correctly. 包含TestCase.php无效,因为它不是Bootstrap文件,因此无法正确加载PHPUnit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM