Class __PHP_Incomplete_Class has no unserializer
Asked Answered
M

5

14

I am trying to run the tests in PHPUnit and getting this error.

Fatal error: Uncaught exception 'ErrorException' with message 'Class __PHP_Incomplete_Class has no unserializer' in /opt/lampp/lib/php/PHPUnit/Util/PHP.php:237

PHP - 5.4.7
PHPUnit - 3.7.21

PHPUnit setting :

processIsolation = "true"
Marabelle answered 4/6, 2013 at 9:13 Comment(2)
Have you tried googling this? google.co.uk/… Seems to be an issue specific to PHPUnit and symfony2Rillings
https://mcmap.net/q/829525/-unserialize-error-when-runinseparateprocess might be related. When working with a framework that put a PDO connection in its global scope, the solution was to add that variable to the backupglobalblacklist: phpunit.de/manual/3.7/en/fixtures.html#idp7165424Papistry
P
11

Try clearing the cache for the test environment. php app/console cache:clear --env=test

Prairial answered 10/7, 2013 at 20:5 Comment(1)
Thanks, but it did not work, I know the reason but i am not sure about it since i do not have any solution to it. This problem is due do the "GLOBALS" handling differently in PHP and PHPUNIT, i have even tried out this option(phpunit.de/manual/3.7/en/…)Marabelle
D
10

Here's a debugging solution that might help you finding where the unserialize method is failing:

<?php
ini_set('unserialize_callback_func', 'debug_unserialize');

function debug_unserialize($classname) 
{
    die(var_dump($classname));
}

That way you will see which classname is causing problem.

Dynamo answered 15/9, 2014 at 12:30 Comment(1)
Useful command. However, my output shows a class that does not exist. Any ideas on why that would be? I have a feeling it is due to something gone wrong with composer or the cache, but I have cleared both and re-installed composer packagesWeissman
C
1

Try opening your site in a browser and then again try to execute the test. I am sure it would work, it seems that there is some difference in cache generation by Php Unit and by Symfony

Caryopsis answered 4/6, 2013 at 10:41 Comment(0)
H
0

Updating symfony to symfony 3.3.18 works for me!

Heart answered 11/6, 2019 at 6:20 Comment(0)
C
0

it works well for me:

rm -rf var/cache/
Caron answered 7/6, 2024 at 9:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.