douyue6520 2014-03-19 10:09
浏览 63
已采纳

PHPUnit抱怨缺少PHPUnit_Extensions_Story_TestCase

Lately I've been having problems with PHPUnit, which keeps complaining about missing PHPUnit_Extensions_Story_TestCase despite the fact that the extension is installed (previous installed using pear install phpunit/PHPUnit_Story). This only happens when I'm running a unit test that fails. So, instead of having a "normal" proper failure stack trace, I have something like this:

ECould not find PHPUnit_Extensions_Story_TestCase

#0  PHPUnit_Util_Fileloader::{closure}(PHPUnit_Extensions_Story_TestCase) called at [/Users/pedro/Code/Repositories/api-v2/src/XXX/system/Autoloader.php:40]
#1  Autoloader->autoload(PHPUnit_Extensions_Story_TestCase)
#2  spl_autoload_call(PHPUnit_Extensions_Story_TestCase)
#3  class_exists(PHPUnit_Extensions_Story_TestCase) called at [phar:///usr/bin/phpunit/phpunit/Util/Blacklist.php:110]
#4  PHPUnit_Util_Blacklist->initialize() called at [phar:///usr/bin/phpunit/phpunit/Util/Blacklist.php:74]
#5  PHPUnit_Util_Blacklist->isBlacklisted(phar:///usr/bin/phpunit/php-invoker/Invoker.php) called at [phar:///usr/bin/phpunit/phpunit/Util/Filter.php:105]
#6  PHPUnit_Util_Filter::getFilteredStacktrace(PHP_Invoker_TimeoutException Object ([] => Execution aborted after 5 seconds,[] => ,[] => 0,[] => phar:///usr/bin/phpunit/php-invoker/Invoker.php,[] => 111,[] => Array ([0] => Array ([file] => /Users/pedro/Code/Repositories/api-v2/src/XXX/data/adapters/MySQLiAdapter.php,[line] => 160,[function] => callback,[class] => PHP_Invoker,[type] => ->,[args] => Array ([0] => 14)),[1] => Array ([file] => /Users/pedro/Code/Repositories/api-v2/src/XXX/data/adapters/MySQLiAdapter.php,[line] => 306,[function] => query,[class] => XXX\data\adapters\MySQLiAdapter,[type] => ->,[args] => Array ([0] => SELECT * FROM `users` ORDER BY RAND() LIMIT 82 )),[2] => Array ([file] => /Users/pedro/Code/Repositories/api-v2/src/XXX/data/objects/Mapper.php,[line] => 138,[function] => select,[class] => XXX\data\adapters\MySQLiAdapter,[type] => ->,[args] => Array ([0] => `users`,[1] => ,[2] => RAND(),[3] => 82)),[3] => Array ([file] => /Users/pedro/Code/Repositories/api-v2/src/XXX/resources/hybrid/Users.php,[line] => 53,[function] => read,[class] => XXX\data\objects\Mapper,[type] => ->,[args] => Array ([0] => RAND(),[1] => 82)),[4] => Array ([function] => read,[class] => XXXesources\hybrid\Users,[type] => ->,[args] => Array ([0] => XXX\data\objects\Operation Object

This goes on how don't know how many hundreds of lines more until if finally tells the actual problem:

Time: 20.35 seconds, Memory: 18.50Mb

There was 1 failure:

1) Tests\XXXesources\hybrid\NotificationsTest::testReadNotificationsWithLimit
Failed asserting that '4567135422196220076' matches expected 4567135456555958453.

/Users/pedro/Code/Repositories/api-v2/tests/XXX/resources/hybrid/NotificationsTest.php:168

FAILURES!
Tests: 5, Assertions: 15, Failures: 1.

Generating code coverage report in Clover XML format ...

I'm running PHPUnit 4.0.10 and have installed PHPUnit_Story-1.0.2 . I understand that this is not a normal behaviour, but unfortunately I don't know how to get rid of this. Any suggestions?

P.S. - I was checking /usr/bin/phpunit file and in the autoload function, the $classes array is missing an entry with 'phpunit_extensions_story_testcase' ...but if I try to edit the file, Phar complains about invalid signature.

  • 写回答

3条回答 默认 最新

  • duansang8388 2014-05-14 11:29
    关注

    Your custom autoloader at /Users/pedro/Code/Repositories/api-v2/src/XXX/system/Autoloader.php is outputting that stuff instead of returning false on line 40. Without seeing the source code of said autoloader, it's impossible to say why that is happening.

    PHP autoloaders are supposed to silently return false if a class cannot be loaded. This is required to allow chaining multiple autoloaders. PHPUnit uses its own autoloader for its own code which cannot run correctly due to your custom autoloader not following the spec.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用