Pregunta

I'm developing a bigger PHP application with symfony2 framework in netbeans 8.0 on a debian 7.0 system. I've written lots of unit tests for helper classes and services and they're running fine in netbeans as well as on command line. But I want to test the controllers as well, so I wrote my first "WebTestCase" derived class:

<?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', '/');
    }
}

Not neccessarily a masterpiece, but it's enough to demonstrate the problem:

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

It's absolutely irrelevant which url I speficy, the error remains the same. So I emptied my routing.yml completely but wrote a single entry for '/' pointing to a new SimpleController which just returns a Rensponse('OK', 200); The error remains.

That's very frustrating especially because the application runs in browser just fine and all the other unit tests are working fully.

Any hints or ideas what I'm doing wrong?

Thanks in advance Hennes

¿Fue útil?

Solución

I had a similiar problem and I solved it increasing the value of xdebug.max_nesting_level in my php.ini. You can obtain information about this setting in http://xdebug.org/docs/all_settings#max_nesting_level

If you don't want to change your php.ini file, you could change the value in php using the ini_set function:

ini_set('xdebug.max_nesting_level', 250);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top