简体   繁体   English

PHPUnit CodeIgniter生成夹具PHP致命错误:未找到类“ PHPUnit_Framework_TestCase”

[英]PHPUnit CodeIgniter Generate Fixtures PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found

So have PHPUnit and CodeIgniter installed: 因此,安装了PHPUnit和CodeIgniter:

http://d.hatena.ne.jp/Kenji_s/20120117/1326763908 http://d.hatena.ne.jp/Kenji_s/20120117/1326763908

Couldn't download the PEAR as its been deprecated. 由于PEAR已被弃用,因此无法下载。 So had to download the phpunit phar file: 所以不得不下载phpunit phar文件:

http://phpunit.de/manual/4.0/en/installation.html#installation.phar http://phpunit.de/manual/4.0/en/installation.html#installation.phar

So was able to get some tests to run properly. 因此能够进行一些测试以使其正常运行。 Moved my phpunit.phar to /usr/local/bin and ran on the tests dir: 将我的phpunit.phar移至/ usr / local / bin并运行测试目录:

php /usr/local/bin/phpunit.phar

And all the tests ran correctly. 并且所有测试均正确运行。 But when i tried to run the php generate fixtures and php generate.php fixtures: 但是,当我尝试运行php生成固定装置和php generate.php固定装置时:

PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in  /www/test/application/third_party/CIUnit/libraries/CIUnitTestCase.php on line 15

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /www/test/application/third_party/CIUnit/libraries/CIUnitTestCase.php on line 15

Seems like its not finding the classes inside the phar file or at least they are not in the correct order? 好像没有找到phar文件中的类,或者至少它们的顺序不正确? What is funny is that it runs the tests fine but not the generate fixtures. 有趣的是,它可以很好地运行测试,但不能生成固定装置。

Additionally i also installed using composer the phpunit so i have a /www/test/vendor/bin/phpunit installed as well. 另外,我还使用composer安装了phpunit,因此我也安装了/ www / test / vendor / bin / phpunit。

Any help would be appreciated. 任何帮助,将不胜感激。

I had the same problem in my code, although I do not use the CodeIgniter. 尽管我不使用CodeIgniter,但我的代码中也遇到了同样的问题。 Trying to run tests would result in the error message: 尝试运行测试将导致错误消息:

Class 'PHPUnit_Framework_TestCase' not found 找不到类“ PHPUnit_Framework_TestCase”

For what it's worth I had this fixed by adding a backslash to my test class declaration. 值得的是,通过在测试类声明中添加反斜杠来解决此问题。

// Before
namespace IMAVendor\Super\Duper;

class MyClassTest extends PHPUnit_Framework_TestCase

// After
namespace IMAVendor\Super\Duper;

class MyClassTest extends \PHPUnit_Framework_TestCase
                          ^
                Added this backslash here

This seems to have something to do with namespaces and the autoloader that's built in phpunit. 这似乎与名称空间和phpunit中内置的自动加载器有关。 I have my own autoloader for the project code and it seems that it was trying to load the phpunit's classes from my code. 我有用于项目代码的自动加载程序,似乎它正在尝试从我的代码加载phpunit的类。 I'm not really sure why it didn't try to load it from the 'base' when it wasn't able to find it in the projects namespace (This may very well be due to my own autoloader being faulty). 我不太确定为什么在项目名称空间中找不到它时为什么不尝试从“基础”中加载它(这很可能是由于我自己的自动加载器出错)。

I know this is an old question, but I'll just leave this here in case it may help somebody somewhere. 我知道这是一个古老的问题,但是我会把它留在这里,以防可能对某人有所帮助。

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

相关问题 PHP 致命错误:找不到类“PHPUnit_Framework_TestCase” - PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found Symfony:致命错误:找不到类'PHPUnit_Framework_TestCase' - Symfony: Fatal error: Class 'PHPUnit_Framework_TestCase' not found in 致命错误:找不到类'PHPUnit_Framework_TestCase' - Fatal error: Class 'PHPUnit_Framework_TestCase' not found 为什么,致命错误:在...中找不到类“PHPUnit_Framework_TestCase”? - Why, Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...? 致命错误:在第24行的dbunit \\ PHPUnit \\ Extensions \\ Database \\ TestCase.php中找不到类“ PHPUnit_Framework_TestCase” - Fatal error: Class 'PHPUnit_Framework_TestCase' not found in dbunit\PHPUnit\Extensions\Database\TestCase.php on line 24 PHP 单元 - 找不到类“PHPUnit_Framework_TestCase” - PHP unit - Class 'PHPUnit_Framework_TestCase' not found PHPUnit类“错误”不会扩展PHPUnit_Framework_TestCase - PHPUnit Class “Error” does not extend PHPUnit_Framework_TestCase phpunit 8 和 PHPUnit_Framework_TestCase - phpunit 8 and PHPUnit_Framework_TestCase PHP 致命错误:在 PHPUnit 6 和 PHP 7.0 中找不到“PHPUnit\\Framework\\TestCase”类 - PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found with PHPUnit 6 and PHP 7.0 在Symfony2项目中找不到类'PHPUnit_Framework_TestCase' - Class 'PHPUnit_Framework_TestCase' not found in Symfony2 project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM