简体   繁体   English

使用\\ PHPUnit_Framework_TestCase或.. \\ TestCase

[英]Use \PHPUnit_Framework_TestCase or ..\TestCase

Stupid question... In the Symfony docs, unit test classes extend \\PHPUnit_Framework_TestCase but in PHPUnit docs, test classes extend PHPUnit\\Framework\\TestCase . 愚蠢的问题......在Symfony文档中,单元测试类扩展了\\PHPUnit_Framework_TestCase但在PHPUnit文档中,测试类扩展了PHPUnit\\Framework\\TestCase Is there a difference, are they the same, or am I missing a subtle PHP feature where _ is equivalent to \\ ? 有没有区别,它们是相同的,还是我错过了一个微妙的PHP功能,其中_相当于\\

Short of actually testing it out myself, can I use either, or just one in Symfony? 没有实际测试它自己,我可以使用,或只在Symfony中使用一个?

Update : It's been helpfully explained to me that these two classes are just a difference between PHPUnit versions. 更新 :有人向我解释说,这两个类只是PHPUnit版本之间的区别。 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. 在我自己的研究和记录之后,Symfony 3.1仍在其自己的KernelTestCase类中扩展\\PHPUnit_Framework_TestCase ,该类为Symfony的功能测试提供支持。 To avoid breaking code, I'm going to play safe & extend WebTestCase that inherits from \\PHPUnit_Framework_TestCase when unit testing with Symfony specifically. 为了避免破坏代码,在安装Symfony进行单元测试时,我将安全地播放并继承继承自\\PHPUnit_Framework_TestCase WebTestCase Such unit tests still work with PHPUnit 5.6 anyway 无论如何,这样的单元测试仍然适用于PHPUnit 5.6

These are the same but since PHPUnit 5.4 it's recommended to use TestCase . 这些是相同的,但自PHPUnit 5.4以来,建议使用TestCase However, it's not a problem if you stay with PHPUnit_Framework_TestCase . 但是,如果你继续使用PHPUnit_Framework_TestCase ,这不是问题。

See a very similar question: PHPUnit can't found the "TestCase" class 看到一个非常相似的问题: PHPUnit找不到“TestCase”类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 phpunit 8 和 PHPUnit_Framework_TestCase - phpunit 8 and PHPUnit_Framework_TestCase 如何使用此文件PHPunit测试“扩展PHPUnit_Framework_TestCase” - How to use this File PHPunit test “extend PHPUnit_Framework_TestCase” 是否可以在不扩展PHPUnit_Framework_TestCase的情况下使用PHPUnit断言? - Is it possible to use PHPUnit assertions without extending PHPUnit_Framework_TestCase? 找不到Symfony / PHPUnitClass'PHPUnit_Framework_TestCase' - Symfony/PHPUnitClass 'PHPUnit_Framework_TestCase' not found PHPUnit类“错误”不会扩展PHPUnit_Framework_TestCase - PHPUnit Class “Error” does not extend PHPUnit_Framework_TestCase PHPUnit:dataProvider在PHPUnit_Framework_TestCase的子类中不起作用 - PHPUnit: dataProvider not working in the sub classes of PHPUnit_Framework_TestCase PHPUnit-如何在PHPUnit_Framework_TestCase中实例化我的pdo类? - PHPUnit - How to instantiate my pdo class in PHPUnit_Framework_TestCase? PHPUnit_Framework_TestCase类不可用。 解决…-Makegood,Eclipse - PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse Selenium RC-无法重新声明类PHPUnit_Framework_TestCase - Selenium RC - Cannot redeclare class PHPUnit_Framework_TestCase PHPUnit_Framework_TestCase找到但未定义的方法:: call() - PHPUnit_Framework_TestCase Found but undefined method ::call()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM