I am trying to use PHPUnit testing with Laravel 5.2.10. I have PHPUnit 5.1.4 installed locally within my project.
When I run:
phpunit
PHPUnit runs all tests in my test directory perfectly.
However, when I run:
phpunit tests/unit/testThatFails.php
I get:
PHP Fatal error: Class 'PHPUNIT_Framework_TestCase' not found in ...
The strange thing is that when I run phpunit it is succesfully running every test in the test directory, including this testThatFails.php just fine.
Why does it break when I try to run just one test?
Update:
Here is my phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
Update:
For now, since I am using Laravel, I am circumventing this issue by extending TestCase rather than PHPUNIT_Framework_TestCase, and my tests are able to run as expected. However, this is just a circumvention and not a solution. (It is also strange to me that this works given the fact that TestCase itself does ultimately extend from PHPUNIT_Framework_TestCase.