Phpunit: You cannot serialize or unserialize PDO instances

Created on 8 Mar 2014  ·  4Comments  ·  Source: sebastianbergmann/phpunit

Hello,
when i have run using bin/phpunit -c app/ src/MyBundle/Tests/Controller/TestControllerTest.php
given me following error, i have finding many ways but not getting any solutions regarding it,

1) MyBundleTests\ControllerTestControllerTest::testJsonPutTestActionShouldModify
PHPUnit_Framework_Exception: PHP Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances' in C:\Users\php52AppD
ata\LocalTemp\PHPB2A7.tmp:49
Stack trace:

0 [internal function]: PDO->__sleep()

1 C:\Users\php52AppData\LocalTemp\PHPB2A7.tmp(49): serialize(Array)

2 C:\Users\php52AppData\LocalTemp\PHPB2A7.tmp(160): __phpunit_run_isolated_test()

3 -(1): require_once('C:\Users\php52...')

4 {main}

thrown in C:\Users\php52AppData\LocalTemp\PHPB2A7.tmp on line 49

Thanks

Most helpful comment

You need to disable process isolation if you want to test objects which do not support serialization (e.g. PDO objects).

All 4 comments

You need to disable process isolation if you want to test objects which do not support serialization (e.g. PDO objects).

@whatthejeff

You need to disable process isolation if you want to test objects which do not support serialization (e.g. PDO objects).

How to do that ?

By not turning it on :-) It is disabled by default.

Yeah I figured out ;) .Indeed in my symfony2 project it was enabled in phpunit.xml.dist

backupGlobals = "false"
processIsolation = "true"

Was this page helpful?
0 / 5 - 0 ratings