ZF + Doctrine2 error phpUnit: PDOExeption: you cannot serialize or unserialize PDO instances

I am using dynamicGuys doctrine2 integration within zend framework (https://github.com/dynamicguy/zf1doctrine2). It works, but if I want to do tests with phpUnit, I get this error: PDOExeption: you cannot serialize or unserialize PDO instances

I searched a bit and I found out that if I comment on line 44 in this file: https://github.com/dynamicguy/zf1doctrine2/blob/master/library/ZendX/Doctrine2/Application/Resource/Entitymanagerfactory.php phpUnit works, but, of course, the rest of the application does not work, since the object manager will not be returned

Any ideas on where the error comes from?

+4
source share
1 answer

This has something to do with PHPUnit for backing up global variables and static attributes between each test. If you have a PDO instance, it breaks up when you try to serialize. I ran into a similar problem, and I could not find where the PDO instance was saved as a global parameter, but disconnected backupGlobals and backupStaticAttributes in the right check, it helped.

/** * Search test. * * @backupGlobals disabled * @backupStaticAttributes disabled * * @author Steven Rosato */ class SearchControllerTest extends \Majisti\Test\TestCase { ... } 

source: http://sebastian-bergmann.de/archives/797-Global-Variables-and-PHPUnit.html

+4
source

Source: https://habr.com/ru/post/1342839/


All Articles