Stupid question... In the Symfony docs, unit test classes extend \\PHPUnit_Framework_TestCase
but in PHPUnit docs, test classes extend PHPUnit\\Framework\\TestCase
. 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 between PHPUnit versions. After my own research and for the record, Symfony 3.1 still extends \\PHPUnit_Framework_TestCase
in its own KernelTestCase
class that powers Symfony's functional testing. To avoid breaking code, I'm going to play safe & extend WebTestCase
that inherits from \\PHPUnit_Framework_TestCase
when unit testing with Symfony specifically. Such unit tests still work with PHPUnit 5.6 anyway
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.