Modify

Ticket #370 (closed defect: duplicate)

Opened 2 years ago

Last modified 2 years ago

Fatal error: Cannot redeclare class PHPUnit_Framework_TestSuite

Reported by: pickscrape@… Owned by: mrook
Priority: major Milestone: 2.4.0RC2
Component: phing-tasks-phpunit Version: devel
Keywords: Cc:

Description

Hi,

I'm encountering this problem with phing 2.4.0RC1 and phpunit 3.4.1.

phpunit works fine when run individually, but when run via phing I get the above exception.

The file that is declaring the class is /usr/share/php/PHPUnit/Framework/TestSuite.php

I've added some tracing to see where the files are being included from to get an idea of what the problem is (by hackishly doing a throw/catch within TestSuite.php to get a useful backtrace), The two backtraces are as follows:

Included:
#0 /usr/share/php/phing/tasks/ext/phpunit/PHPUnitTestRunner.php(22): require_once()
#1 /usr/share/php/phing/tasks/ext/phpunit/PHPUnitTask.php(83): require_once('/usr/share/php/...')
#2 /usr/share/php/phing/parser/TaskHandler.php(164): PHPUnitTask->init()                         
#3 /usr/share/php/phing/parser/TargetHandler.php(177): TaskHandler->init('phpunit', Array)       
#4 /usr/share/php/phing/parser/AbstractSAXParser.php(74): TargetHandler->startElement('phpunit', Array)
#5 [internal function]: AbstractSAXParser->startElement(Resource id #554, 'phpunit', Array)            
#6 /usr/share/php/phing/parser/ExpatParser.php(129): xml_parse(Resource id #554, '<?xml version="...', 1)
#7 /usr/share/php/phing/parser/ProjectConfigurator.php(187): ExpatParser->parse()                        
#8 /usr/share/php/phing/parser/ProjectConfigurator.php(77): ProjectConfigurator->parse()                 
#9 /usr/share/php/phing/Phing.php(526): ProjectConfigurator::configureProject(Object(Project), Object(PhingFile))
#10 /usr/share/php/phing/Phing.php(170): Phing->runBuild()                                                       
#11 /usr/share/php/phing/Phing.php(270): Phing::start(Array, NULL)                                               
#12 /usr/share/php/phing.php(42): Phing::fire(Array)                                                             
#13 {main}                                                              

Included:
#0 /usr/share/php/PHPUnit/Framework.php(69): require()
#1 /usr/share/php/PHPUnit/Framework/TestSuite.php(57): require_once('/usr/share/php/...')
#2 /usr/share/php/phing/tasks/ext/phpunit/PHPUnitTestRunner.php(22): require_once('/usr/share/php/...')
#3 /usr/share/php/phing/tasks/ext/phpunit/PHPUnitTask.php(83): require_once('/usr/share/php/...')      
#4 /usr/share/php/phing/parser/TaskHandler.php(164): PHPUnitTask->init()                               
#5 /usr/share/php/phing/parser/TargetHandler.php(177): TaskHandler->init('phpunit', Array)
#6 /usr/share/php/phing/parser/AbstractSAXParser.php(74): TargetHandler->startElement('phpunit', Array)
#7 [internal function]: AbstractSAXParser->startElement(Resource id #554, 'phpunit', Array)
#8 /usr/share/php/phing/parser/ExpatParser.php(129): xml_parse(Resource id #554, '<?xml version="...', 1)
#9 /usr/share/php/phing/parser/ProjectConfigurator.php(187): ExpatParser->parse()
#10 /usr/share/php/phing/parser/ProjectConfigurator.php(77): ProjectConfigurator->parse()
#11 /usr/share/php/phing/Phing.php(526): ProjectConfigurator::configureProject(Object(Project), Object(PhingFile))
#12 /usr/share/php/phing/Phing.php(170): Phing->runBuild()
#13 /usr/share/php/phing/Phing.php(270): Phing::start(Array, NULL)
#14 /usr/share/php/phing.php(42): Phing::fire(Array)
#15 {main}

Since phpunit is using plain old require in Framework.php (no idea why), it seems that a little more care needs to be taken when including things from phpunit as a result.

I was able to work around this problem by changing /usr/share/php/phing/tasks/ext/phpunit/PHPUnitTestRunner.php to include PHPUnit/Framework.php instead of PHPUnit/Framework/TestSuite.php.

Attachments

Change History

comment:1 Changed 2 years ago by mrook

  • Status changed from new to closed
  • Resolution set to duplicate

This issue was fixed in r592 (also see ticket #363) and will be included in 2.4.0RC2, thanks for the report!

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.