phpunit-selenium icon indicating copy to clipboard operation
phpunit-selenium copied to clipboard

Failing test ran in an isolated process complains about closures that can not be serialized

Open cyberwolf opened this issue 11 years ago • 1 comments

If I run a test using phpunit-selenium in process isolation, if it fails to find certain elements using the selenium API, it ends up not showing the expected exception but instead something like this:

PHPUnit_Framework_Exception: Exception: Serialization of "Closure" is not allowed in serialize() (line 72 of -)

I was able to trace back the problem to PHPUnit_Extensions_Selenium2TestCase_CommandsHolder, which puts a series of anonymous functions in its $commands member instance. Have been able to work around the problem by adding a __sleep() implementation in that same class, so it does not try to serialize $commands any longer:

 public function __sleep() {
        return array(
            'url',
            'driver',
        );
    }

cyberwolf avatar Sep 08 '14 12:09 cyberwolf

Seems backward compatible, I will cherry-pick the commit inside the master branch.

giorgiosironi avatar Sep 14 '14 20:09 giorgiosironi