SomeDude SomeDude - 11 months ago 88
PHP Question

Use PHPUnit_Framework_TestCase or \TestCase

Stupid question... In the Symfony docs, unit test classes extend

but in PHPUnit docs, test classes extend
. Is there a difference, are they the same, or am I missing a subtle PHP feature where
is equivalent to

Short of actually testing it out myself, can I use either, or just one in Symfony?

Update: It's been helpfully explained to me that these two classes are just a difference of which PHPUnit version you're using. After my own research and for the record, Symfony 3.1 still extends
in its own
class that is the core of its own functional testing functions. To avoid breaking code, I'm going to play safe & extend the older
when unit testing with Symfony specifically. These tests still work with PHPUnit 5.6 anyway

Answer Source

These are the same but since PHPUnit 5.4 it's recommended to use TestCase. However, it's not a problem if you stay with PHPUnit_Framework_TestCase.

See a very similar question: PHPUnit can't found the "TestCase" class