This error occurs when a global variable is present that has an array containing a PDO instance assigned to it.
The issue appears to stem from lack of support for this particular scenario in Snapshot->canBeSerialized().
I encountered this behavior while running PHPUnit tests in an environment where PHP configured to use xhprof, which unfortunately uses a global for its configuration and contains a PDO instance in said configuration.
It's possible this issue may be resolved with #3. Until it is, it appears there's no way to run PHPUnit with @backupGlobals and xhprof enabled without modifying xhprof core files.
Thank you for creating this issue. #3 looks indeed like a rescue. I just wanted to bring up the same issue in the context of @backupStaticAttributes. Snapshot::canBeSerialized() does look only at the directly passed attribute (from snapshotStaticAttributes()). Unfortunately if any deeper property of that passed object does have an unserializable object it bails out.
Don't use mockery because of sebastianbergmann/global-state#8
[#3] Don't use mockery because of sebastianbergmann/global-state#8