Skip to content

Instantly share code, notes, and snippets.

@chartjes
Created October 22, 2015 17:41
Show Gist options
  • Save chartjes/fc28115c80b63baabc53 to your computer and use it in GitHub Desktop.
Save chartjes/fc28115c80b63baabc53 to your computer and use it in GitHub Desktop.
PHPUnit 4.8.15 by Sebastian Bergmann and contributors.
PHP Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php:170
Stack trace:
#0 /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php(170): serialize(Object(Zend_Application))
#1 /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php(142): PHPUnit_Util_GlobalState::exportVariable(Object(Zend_Application))
#2 /vagrant/vendor/phpunit/phpunit/src/Framework/TestCase.php(641): PHPUnit_Util_GlobalState::getGlobalsAsString()
#3 /vagrant/vendor/phpunit/phpunit/src/Framework/TestSuite.php(747): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#4 /vagrant/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#5 /vagrant/vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#6 /vagrant/vendor/phpunit/phpunit/src/TextUI/Command.php(100): PHPUnit_TextUI_Command->run in /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php on line 170
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php on line 170
Exception: Serialization of 'Closure' is not allowed in /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php on line 170
Call Stack:
0.0005 636776 1. {main}() /vagrant/vendor/phpunit/phpunit/phpunit:0
0.1971 6140024 2. PHPUnit_TextUI_Command::main() /vagrant/vendor/phpunit/phpunit/phpunit:47
0.1971 6140776 3. PHPUnit_TextUI_Command->run() /vagrant/vendor/phpunit/phpunit/src/TextUI/Command.php:100
9.0741 39696392 4. PHPUnit_TextUI_TestRunner->doRun() /vagrant/vendor/phpunit/phpunit/src/TextUI/Command.php:149
9.1016 40064616 5. PHPUnit_Framework_TestSuite->run() /vagrant/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:440
9.1164 40085608 6. PHPUnit_Framework_TestCase->run() /vagrant/vendor/phpunit/phpunit/src/Framework/TestSuite.php:747
9.1273 40159120 7. PHPUnit_Util_GlobalState::getGlobalsAsString() /vagrant/vendor/phpunit/phpunit/src/Framework/TestCase.php:641
9.1321 40347152 8. PHPUnit_Util_GlobalState::exportVariable() /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php:142
9.1321 40347200 9. serialize() /vagrant/vendor/phpunit/phpunit/src/Util/GlobalState.php:170
@jaydiablo
Copy link

Run into this from time to time, you could try disabling backing up of globals and see if it goes away. Possible you have something in the global scope that has a closure as a public property that PHPUnit is trying to serialize between tests.

@ciaranmcnulty
Copy link

This will happen if you have nonserialisable objects as globals. Try running with --no-globals-backup or eliminate the global scope you're using (i.e. move things inside the scope of your tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment