Not technically related to your issue. However, I had a really hard time trying to solve the "serialization of ' Closure ' isn't allowed" issue while using Phpuni T, and this question is the top Google result.
The problem comes from the fact, PHPUnit serializes all the $GLOBALS in the system to essential back them the Test is running. It then restores them after the test was done.
However, if you had any closures in your GLOBAL space, it's going to cause problems. There ' s ways to solve it.
You can disable the global backup procedure totally by using a annotation.
/**
* @backupGlobals Disabled
*/
Class MyTest extends Phpunit_framework_testcase
{
// ...
}
Or, if you know which variable are causing the problem (look for a lambda in Var_dump ($GLOBALS)), can just blacklist th E problem variable (s).
Class MyTest extends Phpunit_framework_testcase
{
Protected $backupGlobalsBlacklist = Array (' Application ');
// ...
}
Project in PHPUnit unit test times wrong: "Serialization of ' Closure ' is not allowed", here because PHPUnit all the $globals are serialized, and then after the execution of the release, So if you have closures in the global domain, you will get an error saying ' The serialization of closures is not allowed ', only because of the phpunit and mechanism, and the application level is irrelevant. The workaround is to add a declaration in front of the class PHPUnit unit test, disable backupglobals, and translate to global backtracking, as above.