Cakephp You Cannot Serialize Or Unserialize Pdo Instances

02.09.2019by admin
Active3 years, 9 months ago
  1. Cakephp You Cannot Serialize Or Unserialize Pdo Instances

I've recently set up PHPUnit in PHPStorm via Composer.

PDOException You cannot serialize or unserialize PDO instances I have searched for solution in the issues, and on the internet, but could not find any. Any kind of help would be really appreciated. PDOException: You cannot serialize or unserialize PDO instances I think the Session class needs to check if the storage can be serialized, maybe by using a NotSerializable interface, as @fabpot blogged about a while ago.

I'm trying to test some functionality that requires me to bootstrap Processwire (a CMS).

I keep constantly getting the message 'You cannot serialize or unserialize PDO instances' despite applying the conditions below which I researched to be the correct way of fixing this issue.

Is there anything else I have missed or need to do to get this working?

These are the resources I have referenced so far.

Cakephp You Cannot Serialize Or Unserialize Pdo Instances

I've seen this article that flagged my article as a duplicate but I don't believe it to be the same :PDOException: You cannot serialize or unserialize PDO instances

Instances

The test in that article has direct references to the PDO object whereas I'm just trying to get my tests to run with a bootstrap reference to Processwire.This is my test I'm trying to run :

Cakephp you cannot serialize or unserialize pdo instances
Community
FrancisFrancis

1 Answer

I finally figured it out! For whatever reason, setting the test environment variables in the test was having no effect.

By creating a phpunit.xml configuration, defining the test parameters and creating a reference to it in Phpstorm I was finally able to run the test.

For reference, this was the contents of my phpunit.xml

Serialize

I don't think it matters where the file is placed but I placed it in the test folder where my tests resides.

And I had to reference it in PHPStorm by going through the menu (Language & Framework -> PHP -> PHPUnit) and in the Custom Autoloader section, selecting the default configuration file and pointing it to the phpxml file. If you're using a different method, then go to that menu and set the default configuration there.

Hope this helps somebody out there, as there isn't much information relating to PHPUnit & PHPStorm in conjunction.

FrancisFrancis
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged phppdophpunitprocesswire or ask your own question.