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"

Thanks in advance.

Raptor
  • 53,206
  • 45
  • 230
  • 366
Infinity
  • 531
  • 2
  • 6
  • 11
  • 1
    Have you tried googling this? https://www.google.co.uk/search?q=Class+__PHP_Incomplete_Class+has+no+unserializer Seems to be an issue specific to PHPUnit and symfony2 – Pudge601 Jun 04 '13 at 09:25
  • http://stackoverflow.com/a/14514753/921154 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: http://phpunit.de/manual/3.7/en/fixtures.html#idp7165424 – qrazi Jun 04 '13 at 09:46

4 Answers4

11

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

greg
  • 6,853
  • 15
  • 58
  • 71
  • 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(http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.backupGlobals) – Infinity Jul 12 '13 at 14:08
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.

Gildas
  • 1,158
  • 1
  • 10
  • 25
  • 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 packages – Michael Millar Feb 06 '18 at 16:23
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

naddy19
  • 304
  • 2
  • 12
0

I have the same issue

updating symfony to symfony 3.3.18 works for me !

hope it helps

Jasson Rojas
  • 299
  • 3
  • 12