无法运行PHPUnit WebTestCases

时间:2014-05-07 07:51:19

标签: symfony controller phpunit

我正在debian 7.0系统上的netbeans 8.0中使用symfony2框架开发更大的PHP应用程序。 我已经为帮助程序类和服务编写了大量的单元测试,并且它们在netbeans和命令行中运行良好。 但我也想测试控制器,所以我写了我的第一个" WebTestCase"派生类:

<?php
namespace StockCrawler\MainBundle\Tests\Services;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class TestFrontpageController extends WebTestCase {
    public function testIndexAction() {
        $client = static::createClient();
        $crawler = $client->request('GET', '/');
    }
}

不一定是杰作,但它足以证明这个问题:

PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from /home/hennes/PHP-Projects/StockCrawler/app/phpunit.xml

PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php on line 81
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325
PHP   6. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
PHP   7. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
PHP   8. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751
PHP   9. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649
PHP  10. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:804
PHP  11. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:942
PHP  12. Fotokiste\MainBundle\Tests\Services\TestCircleController->testIndexAction() /usr/share/php/PHPUnit/Framework/TestCase.php:942
PHP  13. Symfony\Component\BrowserKit\Client->request() /home/hennes/PHP-Projects/StockCrawler/src/Fotokiste/MainBundle/Tests/Services/TestCircleController.php:23
PHP  14. Symfony\Bundle\FrameworkBundle\Client->doRequest() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/BrowserKit/Client.php:334
PHP  15. Symfony\Component\HttpKernel\Client->doRequest() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Client.php:111
PHP  16. Symfony\Component\HttpKernel\Kernel->handle() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Client.php:81
PHP  17. Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle() /home/hennes/PHP-Projects/StockCrawler/app/bootstrap.php.cache:2303
PHP  18. Symfony\Component\HttpKernel\HttpKernel->handle() /home/hennes/PHP-Projects/StockCrawler/app/bootstrap.php.cache:3022
PHP  19. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /home/hennes/PHP-Projects/StockCrawler/app/bootstrap.php.cache:2883
PHP  20. Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher->dispatch() /home/hennes/PHP-Projects/StockCrawler/app/bootstrap.php.cache:2900
PHP  21. Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:138
PHP  22. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:167
PHP  23. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:53
PHP  24. call_user_func() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:164
PHP  25. Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher->Symfony\Component\HttpKernel\Debug\{closure}() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:164
PHP  26. call_user_func() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:388
PHP  27. Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:388
PHP  28. Symfony\Component\Routing\Router->matchRequest() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:125
PHP  29. Symfony\Component\Routing\Router->getMatcher() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Router.php:227
PHP  30. Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper->dump() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Router.php:261
PHP  31. Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper->generateMatchMethod() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php:75
PHP  32. Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper->compileRoutes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php:90
PHP  33. Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper->buildPrefixTree() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php:132
PHP  34. Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection->mergeSlashNodes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php:382
PHP  35. Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection->mergeSlashNodes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php:93
PHP  36. Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection->mergeSlashNodes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php:93
PHP  37. Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection->mergeSlashNodes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php:93
 .
 .
 .
PHP  97. Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection->mergeSlashNodes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php:93
PHP  98. Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection->mergeSlashNodes() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php:93
PHP  99. Symfony\Component\Routing\Matcher\Dumper\DumperCollection->getIterator() /home/hennes/PHP-Projects/StockCrawler/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php:91

这与我所说的哪个网址完全无关,错误仍然相同。 所以我完全清空了我的routing.yml,但为&#39; /&#39;写了一个条目。指向一个新的SimpleController,它只返回一个Rensponse(&#39; OK&#39;,200); 错误仍然存​​在。

这非常令人沮丧,特别是因为应用程序在浏览器中运行得很好并且所有其他单元测试都完全正常工作。

我做错了什么提示或想法?

提前致谢 亨尼斯

1 个答案:

答案 0 :(得分:4)

我有一个类似的问题,我解决了它增加了我的php.ini中xdebug.max_nesting_level的值。您可以在http://xdebug.org/docs/all_settings#max_nesting_level

中获取有关此设置的信息

如果您不想更改php.ini文件,可以使用ini_set函数更改php中的值:

ini_set('xdebug.max_nesting_level', 250);