Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You cannot serialize or unserialize PDO instances #1171

Closed
kunjalpopat opened this issue Mar 8, 2014 · 4 comments
Closed

You cannot serialize or unserialize PDO instances #1171

kunjalpopat opened this issue Mar 8, 2014 · 4 comments

Comments

@kunjalpopat
Copy link

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. MyBundle\Tests\Controller\TestControllerTest::testJsonPutTestActionShouldModify
    PHPUnit_Framework_Exception: PHP Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances' in C:\Users\php52\AppD
    ata\Local\Temp\PHPB2A7.tmp:49
    Stack trace:
    #0 [internal function]: PDO->__sleep()
    When backupStaticAttributes is enable, static data from a first test case leaks to the subsequent tests cases #1 C:\Users\php52\AppData\Local\Temp\PHPB2A7.tmp(49): serialize(Array)
    Running with --process-isolation yields parse error on global data with single quotes #2 C:\Users\php52\AppData\Local\Temp\PHPB2A7.tmp(160): __phpunit_run_isolated_test()
    Mocking class Imagick of pecl/imagick 3.0.0 fails with PHPUnit 3.4.2 and 3.5 beta1 #3 -(1): require_once('C:\Users\php52...')
    phpunit.bat on 3.5.0RC1 doesn't work #4 {main}

thrown in C:\Users\php52\AppData\Local\Temp\PHPB2A7.tmp on line 49

Thanks

@whatthejeff
Copy link
Contributor

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

@ousmaneNdiaye
Copy link

@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 ?

@sebastianbergmann
Copy link
Owner

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

@ousmaneNdiaye
Copy link

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

<phpunit
backupGlobals = "false"
processIsolation = "true"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants