What does " Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances'" mean?

If you are running unit tests in PHP, you may get the following hair-pulling error:

Uncaught exception 'PDOException' with message  
    'You cannot serialize or unserialize PDO instances'

It means that something with a doctrine/pdo went wrong in one of your tests. Since serialize does not work on pdo-classes, it prints out this message. If you want doctrines/PDOs message, run only the one test with process isolation turned off and you will get the error-message.

1 comment:

  1. I know that setting processIsolation to "false" in phpunit.xml.dist solve this issue.
    But I am setting it to true since, otherway db connections are not closed and too many connection error raises.

    See: http://stackoverflow.com/questions/16892355/pdo-connection-is-not-closed-when-phpunit-is-running-with-symfony-2-x