sanders sanders - 6 months ago 27
PHP Question

PHPUnit 3.5 keeps showing errors

I am trying to get phpunit 3.5 working. But everytime i run my tests i get this error:

PHP Fatal error: Class 'PHPUnit_Framework_TestFailure' not found in C:\wamp\bin
\php\php5.3.9\pear\PHPUnit\Framework\TestResult.php on line 266
PHP Stack trace:
PHP 1. {main}() C:\wamp\bin\php\php5.3.9\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3.9\phpunit:49
PHP 3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.9\pear\PHPUnit\Tex
tUI\Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() C:\wamp\bin\php\php5.3.9\pear\PHPUni
t\TextUI\Command.php:188
PHP 5. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.3.9\pear\PHPUni
t\TextUI\TestRunner.php:305
PHP 6. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.3.9\pear\PHPUni
t\Framework\TestSuite.php:693
PHP 7. PHPUnit_Framework_TestSuite->runTest() C:\wamp\bin\php\php5.3.9\pear\PH
PUnit\Framework\TestSuite.php:733
PHP 8. PHPUnit_Framework_TestCase->run() C:\wamp\bin\php\php5.3.9\pear\PHPUnit
\Framework\TestSuite.php:757
PHP 9. PHPUnit_Framework_TestResult->run() C:\wamp\bin\php\php5.3.9\pear\PHPUn
it\Framework\TestCase.php:576
PHP 10. PHPUnit_Framework_TestResult->addError() C:\wamp\bin\php\php5.3.9\pear\
PHPUnit\Framework\TestResult.php:717

Fatal error: Class 'PHPUnit_Framework_TestFailure' not found in C:\wamp\bin\php\
php5.3.9\pear\PHPUnit\Framework\TestResult.php on line 266

Call Stack:
0.0004 327336 1. {main}() C:\wamp\bin\php\php5.3.9\phpunit:0
0.3024 699040 2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3
.9\phpunit:49
0.3024 699392 3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.
9\pear\PHPUnit\TextUI\Command.php:129
0.3929 3300128 4. PHPUnit_TextUI_TestRunner->doRun() C:\wamp\bin\php\ph
p5.3.9\pear\PHPUnit\TextUI\Command.php:188
0.4153 3766872 5. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\ph
p5.3.9\pear\PHPUnit\TextUI\TestRunner.php:305
0.4154 3767136 6. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\ph
p5.3.9\pear\PHPUnit\Framework\TestSuite.php:693
0.4155 3767336 7. PHPUnit_Framework_TestSuite->runTest() C:\wamp\bin\ph
p\php5.3.9\pear\PHPUnit\Framework\TestSuite.php:733
0.4155 3767336 8. PHPUnit_Framework_TestCase->run() C:\wamp\bin\php\php
5.3.9\pear\PHPUnit\Framework\TestSuite.php:757
0.4158 3767336 9. PHPUnit_Framework_TestResult->run() C:\wamp\bin\php\p
hp5.3.9\pear\PHPUnit\Framework\TestCase.php:576
0.4257 3934600 10. PHPUnit_Framework_TestResult->addError() C:\wamp\bin\
php\php5.3.9\pear\PHPUnit\Framework\TestResult.php:717


c:\wamp\www\ZendSkeletonApplication\module\page\test>


And this is my include path:

string(252) "C:\wamp\bin\php\php5.3.9\pear\PHPUnit\Autoload.php;C:\wamp\www\Zend
SkeletonApplication\module\page/test;C:\wamp\www\ZendSkeletonApplication\vendor\
ZendFramework\library;.;C:\wamp\bin\php\php5.3.9\pear;C:\pear\pear;C:\pear\pear;
C:\pear\pear;C:\pear\pear"


The file TestFailure doe exist.

So any idea's?

Answer

You should include the full PHPUNit directory in your path and you also must manually include the autoloader. So at the top of your php file, add this:

require 'PHPUnit/Autoload.php'

And in your include path, change the PHPUnit part to just C:\wamp\bin\php\php5.3.9\pear\PHPUnit (instead of what you currently have, C:\wamp\bin\php\php5.3.9\pear\PHPUnit\Autoload.php).