I know, isnt as if Composer or Travis not work, I do not get to do that work fine, I do not understand how autoload runs locally but not in Travis build.
If someone could shed light on this problem that I have, I would be very grateful.
The problem specifically is displayed when you can not find an interface ...
as the error pops up when you do not see the "namespace\namespace\interface", I think that should be the autoload, should not be loading very well for the test in Travis.
Here is:
PHP Fatal error: Interface 'RestGalleries\Interfaces\User' not found in /home/travis/build/estebanmatias92/RestGalleries/src/RestGalleries/APIs/Flickr/FlickrUser.php on line 15
PHP Stack trace:
PHP 1. {main}() /home/travis/.phpenv/versions/5.4.25/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.4.25/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /home/travis/.phpenv/versions/5.4.25/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /home/travis/.phpenv/versions/5.4.25/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP 6. PHPUnit_Framework_TestSuite->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP 7. PHPUnit_Framework_TestSuite->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP 8. PHPUnit_Framework_TestSuite->runTest() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP 9. PHPUnit_Framework_TestCase->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP 10. PHPUnit_Framework_TestResult->run() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP 11. PHPUnit_Framework_TestCase->runBare() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP 12. PHPUnit_Framework_TestCase->runTest() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
PHP 13. ReflectionMethod->invokeArgs() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 14. RestGalleriesTest->testFindUserReturnApiUserObject() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 15. Composer\Autoload\ClassLoader->loadClass() /home/travis/build/estebanmatias92/RestGalleries/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:0
PHP 16. Composer\Autoload\includeFile() /home/travis/build/estebanmatias92/RestGalleries/vendor/composer/ClassLoader.php:269
PHP 17. include() /home/travis/build/estebanmatias92/RestGalleries/vendor/composer/ClassLoader.php:363
Frankly I can not think it can be right now. I leave my code on github and the failing build (Until the time, i have failed at all with this, but leave the last build to see).
Github: https://github.com/estebanmatias92/RestGalleries
Travis CI build: https://travis-ci.org/estebanmatias92/RestGalleries/jobs/19337261
Are you are working on OSX which has case-insensitive filesystem by default? Try renaming the folder interfaces to Interfaces.
Related
For complicated reasons, I'm trying to get a Laravel project running that I did not develop. I'm using a Vagrant/Homestead combination (Host Windows 10, VM Homestead v2.1.8 (Ubuntu 18.04.1) with Laravel 5.0.35, PHP 5.6 - that's what it was created in) and after putting the project there and running composer install, I just tried to have a look at the routes via
php artisan route:list
which gave me the error
PHP Fatal error: Call to a member function make() on null in /home/vagrant/code/newbackend/vendor/compiled.php on line 4823
PHP Stack trace:
PHP 1. {main}() /home/vagrant/code/newbackend/artisan:0
PHP 2. Illuminate\Foundation\Console\Kernel->handle() /home/vagrant/code/newbackend/artisan:36
PHP 3. Symfony\Component\Console\Application->run() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:94
PHP 4. Symfony\Component\Console\Application->doRun() /home/vagrant/code/newbackend/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP 5. Symfony\Component\Console\Application->doRunCommand() /home/vagrant/code/newbackend/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP 6. Illuminate\Console\Command->run() /home/vagrant/code/newbackend/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP 7. Symfony\Component\Console\Command\Command->run() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Console/Command.php:101
PHP 8. Illuminate\Console\Command->execute() /home/vagrant/code/newbackend/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
PHP 9. Illuminate\Container\Container->call() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Console/Command.php:115
PHP 10. call_user_func_array:{/home/vagrant/code/newbackend/vendor/compiled.php:964}() /home/vagrant/code/newbackend/vendor/compiled.php:964
PHP 11. Illuminate\Foundation\Console\RouteListCommand->fire() /home/vagrant/code/newbackend/vendor/compiled.php:964
PHP 12. Illuminate\Foundation\Console\RouteListCommand->getRoutes() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:75
PHP 13. Illuminate\Foundation\Console\RouteListCommand->getRouteInformation() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:89
PHP 14. Illuminate\Foundation\Console\RouteListCommand->getMiddleware() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:109
PHP 15. Illuminate\Foundation\Console\RouteListCommand->getControllerMiddleware() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:142
PHP 16. Illuminate\Foundation\Application->make() /home/vagrant/code/newbackend/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:161
PHP 17. Illuminate\Container\Container->make() /home/vagrant/code/newbackend/vendor/compiled.php:1543
PHP 18. Illuminate\Container\Container->build() /home/vagrant/code/newbackend/vendor/compiled.php:1019
PHP 19. Illuminate\Container\Container->getDependencies() /home/vagrant/code/newbackend/vendor/compiled.php:1081
PHP 20. Illuminate\Container\Container->resolveClass() /home/vagrant/code/newbackend/vendor/compiled.php:1095
PHP 21. Illuminate\Foundation\Application->make() /home/vagrant/code/newbackend/vendor/compiled.php:1111
PHP 22. Illuminate\Container\Container->make() /home/vagrant/code/newbackend/vendor/compiled.php:1543
PHP 23. Illuminate\Container\Container->fireResolvingCallbacks() /home/vagrant/code/newbackend/vendor/compiled.php:1029
PHP 24. Illuminate\Container\Container->fireCallbackArray() /home/vagrant/code/newbackend/vendor/compiled.php:1180
PHP 25. Illuminate\Validation\ValidationServiceProvider->Illuminate\Validation\{closure}() /home/vagrant/code/newbackend/vendor/compiled.php:1195
PHP 26. Illuminate\Foundation\Http\FormRequest->validate() /home/vagrant/code/newbackend/vendor/compiled.php:4699
PHP 27. Illuminate\Foundation\Http\FormRequest->getValidatorInstance() /home/vagrant/code/newbackend/vendor/compiled.php:4772
The error leads me to
$factory = $this->container->make('Illuminate\\Validation\\Factory');
in class FormRequest (extends Request implements ValidatesWhenResolved) on line 4823 in vendor/compiled.php - but that's not telling me much.
As I'm new to Php/laravel and don't quite have a handle on the intricacies of this project, my googling efforts left me more confused than ever. Does anyone have at least a starting point for me on how to resolve this?
I have a backend system based on Symfony 3.x, and I work on PHPStorm 2017.x.
My Server is a regular XAMPP 5.6.8 stack with Apache and MySQL only, and I applied the latest compatible phpunit.phar (5.7.20) to the "php"-folder in the XAMPP-directory. I am supposed to run PHPUnit tests with a Phing buildfile, however the internal PHPStorm terminal displays an error:
Fatal error: Class 'PHPUnit\Framework\TestCase' not found in O:\%PROJECT_DIR%\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php on line 25
In my current project settings, I pointed to the phpunit.phar within my XAMPP-directory, but somehow it still tries to find the phpunit within the Symfony vendor directory. Where exactly is the source of the error and how can I correct it? Is it Phing-based?
EDIT:
Adding the error call stack:
Call Stack:
0.0003 121616 1. {main}() O:\xampp_5_6_8\php\phpunit:0
0.0064 357360 2. PHPUnit_TextUI_Command::main() O:\xampp_5_6_8\php\phpunit:46
0.0064 360760 3. PHPUnit_TextUI_Command->run() O:\xampp_5_6_8\php\pear\PHPUnit\TextUI\Command.php:129
0.0064 361968 4. PHPUnit_TextUI_Command->handleArguments() O:\xampp_5_6_8\php\pear\PHPUnit\TextUI\Command.php:138
0.0212 833056 5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() O:\xampp_5_6_8\php\pear\PHPUnit\TextUI\Command.php:657
0.0212 833720 6. PHPUnit_Util_Configuration->getTestSuite() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Configuration.php:789
0.0609 976960 7. PHPUnit_Framework_TestSuite->addTestFiles() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Configuration.php:873
0.0609 978088 8. PHPUnit_Framework_TestSuite->addTestFile() O:\xampp_5_6_8\php\pear\PHPUnit\Framework\TestSuite.php:416
0.0623 1033248 9. PHPUnit_Util_Fileloader::checkAndLoad() O:\xampp_5_6_8\php\pear\PHPUnit\Framework\TestSuite.php:355
0.0634 1033416 10. PHPUnit_Util_Fileloader::load() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:76
0.0642 1054496 11. include_once('O:\%PROJECT_DIR%\src\App\Bundle\Tests\Controller\ControllerTest.php') O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:92
0.0643 1054728 12. spl_autoload_call() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:11
0.0643 1054784 13. Composer\Autoload\ClassLoader->loadClass() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:0
0.0647 1054960 14. Composer\Autoload\includeFile() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:301
0.0653 1059352 15. include('O:\%PROJECT_DIR%\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\WebTestCase.php') O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:414
0.0653 1059592 16. spl_autoload_call() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:22
0.0653 1059656 17. Composer\Autoload\ClassLoader->loadClass() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:0
0.0657 1059832 18. Composer\Autoload\includeFile() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:301
0.0664 1091728 19. include('O:\%PROJECT_DIR%\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php') O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:414
PHPUnit\Framework\TestCase is a reference to PhpUnit 6 test version while you're using phpunit.phar (5.7.20).
Try to replace it with the latest 6.* version.
I'm having issues finding the source of an error I'm receiving in PHPUnit. If I run phpunit with no filter I will receive the "bytes exhausted" error.
however if I run my tests one at a time with phpunit --filter test_name - all of my test will pass.
The stack trace posted below indicates a problem with one of my tests called KInit however if run that test by itself everything passes.
I have also tried to move the test out of the directory but the error will simply point to the next test that is run. I have also tried running with sudo which did not work any better.
How can I get more information on whats happening here?
I'm running PHPUint to test a laravel 4.2 app.
versions of stuff
PHPUnit 4.1.4
PHP 5.5.18
Ubuntu 12.04 64-bit
The stack trace below says the error is in:
laravel/framework/src/Illuminate/Filesystem/Filesystem.php
however sometimes it reads
/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
Full stack trace:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 15886 bytes) in /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 31
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:586
PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:132
PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:179
PHP 5. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:426
PHP 6. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 7. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 8. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 9. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:758
PHP 10. PHPUnit_Framework_TestCase->runBare() phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php:686
PHP 11. KInitTest->setUp() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:818
PHP 12. TestCase->setUp() /opt/pplus/laravel/app/tests/unit/classes/KInit/KInitTest.php:16
PHP 13. Illuminate\Foundation\Testing\TestCase->setUp() /opt/pplus/laravel/app/tests/TestCase.php:35
PHP 14. Illuminate\Foundation\Testing\TestCase->refreshApplication() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:31
PHP 15. TestCase->createApplication() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:42
PHP 16. require() /opt/pplus/laravel/app/tests/TestCase.php:17
PHP 17. require() /opt/pplus/laravel/bootstrap/start.php:60
PHP 18. Illuminate\Foundation\ProviderRepository->load() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/start.php:210
PHP 19. Illuminate\Foundation\ProviderRepository->loadManifest() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:51
PHP 20. Illuminate\Filesystem\Filesystem->get() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:187
PHP 21. file_get_contents() /opt/pplus/laravel/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:31
I found the answer. I had to increase the memory_limit in /etc/php5/cli/php.ini. I always forget the phpunit uses a different ini file than apache.
I have a PHPUnit test suite that is currently causing a fatal error due to a class definition that's not being found. This, ultimately, is a failure of the testing code itself and a failure by the developer to vindicate the test itself before committing code.
However, things like this do happen from time to time, and it would be wonderful if, when a fatal error occurs (regardless of who's ultimately responsible), the test simply be marked as a failure, and the remainder of the test suite still be executed.
I have read about the --process-isolation switch and as far as I can tell, it should take care of this. Since each test runs in a separate process, if the child dies due to a fatal error, the parent can still continue to run. In fact, this is stated explicitly in this answer to a similar question: https://stackoverflow.com/a/5340151/84762 which shows the exact type of output I would like to see myself.
However, I seem to get the exact same output regardless of whether or not I use the --process-isolation flag:
WITHOUT process isolation
[kogi#phagocyte ~]$ /usr/bin/phpunit --colors --verbose --coverage-html "target/coverage" ~/app/zend/tests/application/
PHP Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
PHP 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
PHP 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
PHP 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
PHP 9. include_once() /usr/share/pear/PHPUnit/Util/Fileloader.php:95
PHP 10. require_once() /home/kogi/app/zend/tests/application/translate/PollTest.php:11
Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
Call Stack:
0.0003 91584 1. {main}() /usr/bin/phpunit:0
0.0076 612672 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0076 613744 3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:130
0.0246 1249464 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
0.0706 1626680 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
0.1691 8053584 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
0.1693 8057320 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
0.1694 8057664 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
0.1711 8240600 9. include_once('/home/kogi/app/zend/tests/application/translate/PollTest.php') /usr/share/pear/PHPUnit/Util/Fileloader.php:95
0.1805 9187768 10. require_once('/home/kogi/app/zend/private/models/translate/Poll.php') /home/kogi/app/zend/tests/application/translate/PollTest.php:11
WITH process isolation
[kogi#phagocyte ~]$ /usr/bin/phpunit --colors --verbose --coverage-html "target/coverage" --process-isolation ~/app/zend/tests/application/
PHP Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
PHP 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
PHP 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
PHP 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
PHP 9. include_once() /usr/share/pear/PHPUnit/Util/Fileloader.php:95
PHP 10. require_once() /home/kogi/app/zend/tests/application/translate/PollTest.php:11
Fatal error: Class 'Rmd_Database_OldObject' not found in /home/kogi/app/zend/private/models/translate/Poll.php on line 9
Call Stack:
0.0003 91752 1. {main}() /usr/bin/phpunit:0
0.0076 612824 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0076 613896 3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:130
0.0246 1250360 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/pear/PHPUnit/TextUI/Command.php:150
0.0708 1627528 5. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/pear/PHPUnit/Runner/BaseTestRunner.php:96
0.1688 8054296 6. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/pear/PHPUnit/Framework/TestSuite.php:419
0.1690 8057992 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/pear/PHPUnit/Framework/TestSuite.php:358
0.1691 8058336 8. PHPUnit_Util_Fileloader::load() /usr/share/pear/PHPUnit/Util/Fileloader.php:79
0.1707 8241296 9. include_once('/home/kogi/app/zend/tests/application/translate/PollTest.php') /usr/share/pear/PHPUnit/Util/Fileloader.php:95
0.1801 9188464 10. require_once('/home/kogi/app/zend/private/models/translate/Poll.php') /home/kogi/app/zend/tests/application/translate/PollTest.php:11
For those of us that can't effectively diff in our heads, the two outputs are literally identical (other than the execution time and memory usage which is negligibly different).
In both cases, the fatal error kills the entire test suite. In this particular case, this happens in the 3rd test and the remaining 150 tests (in several other files/suites) are never executed.
What am I doing wrong here? Is there some other way to survive a fatal error (marking the test as failed) in one test and still execute remaining tests?
EDIT
I am using PHPUnit 3.6.10
EDIT
Comments on the answer to this question have inspired a new ticket on PHPUnit's GitHub page: https://github.com/sebastianbergmann/phpunit/issues/545
PHPUnit loads each test file that will be run before running any tests. This causes PHP to parse these files and execute their top-level code. If any class is loaded that, for example, extends a class that doesn't exist, you'll get a fatal error.
I don't see any way around this without enhancing PHPUnit to parse the files without executing their code during the scanning process.
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?
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).
Try loading it manually, seems like this old version is buggy
require_once 'PHPUnit/Framework/TestFailure.php';