Fatal Error Cannot Redeclare Class Phpunit_framework_testcase In
here for a quick overview of the site Help Center Detailed answers to phpunit cannot redeclare function any questions you might have Meta Discuss the workings and phpunit cannot redeclare class policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Selenium RC - Cannot redeclare class PHPUnit_Framework_TestCase up vote 1 down vote favorite This I have found on the net in various places but with no actual solution. The default code for running a test is 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? Thanks selenium-rc php include-path share|improve this question asked Jan 12 '11 at 15:58 Jake N 7,36683678 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted I have solved this by changing the line require_once 'PHPUnit
♦ Locked 4 messages gaz1234 Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ PHP Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase I have received the below error after following the instructions for unit testing from http://zf2.readthedocs.org/en/release-2.0.3/user-guide/unit-testing.htmlPHP Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase in /Users/gaz/Sites/zfTest/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php on line 98 line 98 of TestCase.php abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing { ....... Versions: ZF2: 2.0.2 PHPUnit: 3.7.7 In an http://stackoverflow.com/questions/4670883/selenium-rc-cannot-redeclare-class-phpunit-framework-testcase attempt to fix this I have upgraded to ZF2: 2.0.3 still no joy! I have gone back over the code to see if I have made a mistake but I can not find anything that would cause this error msg. Marco Pivetta Reply | Threaded Open this post in threaded view ♦ ♦ | http://zend-framework-community.634137.n4.nabble.com/PHP-Fatal-error-Cannot-redeclare-class-PHPUnit-Framework-TestCase-td4657687.html Report Content as Inappropriate ♦ ♦ Re: PHP Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase You should probably run /vendor/bin/phpunit instead of your system PHPUnit... Marco Pivetta http://twitter.com/Ocramiushttp://ocramius.github.com/On 19 October 2012 04:45, gaz1234 <[hidden email]> wrote: > I have received the below error after following the instructions for unit > testing from > > /http://zf2.readthedocs.org/en/release-2.0.3/user-guide/unit-testing.html/> > PHP Fatal error: Cannot redeclare class PHPUnit_Framework_TestCase in > > /Users/gaz/Sites/zfTest/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php > on line 98 > > line 98 of TestCase.php > > abstract class PHPUnit_Framework_TestCase extends PHPUnit_Framework_Assert > implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing > { > ....... > > Versions: > ZF2: 2.0.2 > PHPUnit: 3.7.7 > > In an attempt to fix this I have upgraded to ZF2: 2.0.3 > > still no joy! > > I have gone back over the code to see if I have made a mistake but I can > not > find anything that would cause this error msg. > > > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/PHP-Fatal-error-Cannot-redeclare-class-PHPUnit-Fra
Fix version(s): Reporter: Erik Wegner (eman) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Test_PHPUnit zf-caretaker-adamlundrigan Related issues: Attachments: - ControllerTestCase_require.diff Description https://framework.zend.com/issues/browse/ZF-9380 A simple
php -r "require_once 'PHPUnit/Framework/TestCase.php';" produces the errorFatal error: Cannot redeclare class PHPUnit_Framework_TestCase in C:\xampp\php\PEAR\PHPUnit\Framework\TestCase.php on line 116 The PHPUnit documentation says to include/require PHPUnit/Framework.php to write own derived test cases. My application needs to load the Zend_Test_PHPUnit_ControllerTestCase cannot redeclare class which uses the above require_once statement and therefore produced the error message about class redeclaration. When I replace the statement, my application and my very own tests run fine. Comments Posted by Erik Wegner (eman) on 2010-03-09T07:29:45.000+0000 Patch attached Posted by Thomas cannot redeclare class Bachmann (thobach) on 2010-03-20T09:54:45.000+0000 I have the same problem with PHPUnit 3.4.11 and ZF 1.10.2 and PHP 5.3. Posted by Thomas Bachmann (thobach) on 2010-03-21T08:09:08.000+0000 When I apply the patch to /Zend/Test/PHPUnit/ControllerTestCase.php (remove the line with require_once('...TestCase.php')) I get the following error: Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /usr/local/zend/share/ZendFramework/library/Zend/Test/PHPUnit/ControllerTestCase.php on line 54 Posted by Erik Wegner (eman) on 2010-03-22T04:34:39.000+0000 Did you just remove the line or did you replace it with the newrequire_once 'PHPUnit/Framework.php'; line? Posted by Thomas Bachmann (thobach) on 2010-03-23T12:24:38.000+0000 When I follow one of these instructions: * http://blog.fedecarg.com/2008/12/… * http://zendcasts.com/unit-testing-with-the-zend-fr… I don't need any modification. I guess it is not well documented in the programmer's reference. But if you have a phpunit.xml and call phpunit via the command-line, it should work. Poste