We just started to unit-test our application for our CI; the first tests we have written run through, but PHPUnit always throws a error message at the end:
user@server:~/public$ phpunit -c app/ --strict src/Acme/Bundle/SomeBundle/Tests/Controller/SomeControllerTest.php
PHPUnit 3.6.11 by Sebastian Bergmann.
Configuration read from /var/www/user/htdocs/public/app/phpunit.xml.dist
..
Time: 5 seconds, Memory: 130.00Mb
OO (2 tests, 2 assertions)
PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0
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:133
Fatal error: Exception thrown without a stack frame in Unknown on line 0
Call Stack:
0.0001 629992 1. {main}() /usr/bin/phpunit:0
0.0023 1235832 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
0.0023 1236848 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:133
The only hint so far is that it only occurs if one (or more) of the tests uses [see below] to make a Request on the Page, so its is probably in some way session related.
$client = static::createClient();
$container = $client->getContainer();
$uri = $container->getParameter('url_frontend') . '/';
$client->request('GET', $uri);
Here is a link to our phpunit.xml.dist
Update:
I managed to get a little more information, about the error itself:
1) Acme\Bundle\SomeBundle\Tests\Controller\SomeControllerTest::testIndexResponseStatusCode
RuntimeException: PHP Fatal error: Uncaught exception 'ErrorException' with message 'Warning: Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/tmp/sessions) in Unknown line 0' in /var/www/user/htdocs/public/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php:67
Stack trace:
#0 [internal function]: Symfony\Component\HttpKernel\Debug\ErrorHandler->handle(2, 'Unknown: Failed...', 'Unknown', 0, Array)
#1 {main}
thrown in /var/www/user/htdocs/public/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php on line 67
One of our Developers (after much swearing and cursing) solved the Problem, at fault was the
FOS\FacebookBundle\Facebook\FacebookSessionPersistenceto be precise the fact that the constructor starts its own session:So we just wrote our own FacebookSessionPersistence Class:
And added it in the test config:
Hope that will help future generations…