2011-01-12 111 views
1

這是我在網上發現的各種地方,但沒有實際的解決方案。用於運行測試的默認密碼是Selenium RC - 無法重新聲明類PHPUnit_Framework_TestCase

<?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()); 
    } 

} 
?> 

這給了我下面的錯誤

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

我包括路徑是這樣的

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

誰能幫我解決這個?目前尚不清楚該類重新申報的位置,是上述文件的第115行還是其他地方?

感謝

回答

1

我已經改變線路

require_once 'PHPUnit/Framework/TestCase.php'; 

解決了這個要

require_once 'PHPUnit/Framework.php'; 

Framework.php文件是引導對PHPUnit的和包括該處理與其他具備。包括TestCase.php不起作用,因爲那不是Bootstrap文件,因此不會正確加載PHPUnit。