[wp-trac] [WordPress Trac] #50482: Uncaught Exception: Serialization of 'Closure' is not allowed when run PHPUnit in plugin development

WordPress Trac noreply at wordpress.org
Fri Jun 26 15:10:33 UTC 2020


#50482: Uncaught Exception: Serialization of 'Closure' is not allowed when run
PHPUnit in plugin development
--------------------------+-----------------------------
 Reporter:  yshinoda      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Following error message is presented when I run PHPUnit in plugin
 development with latest trunk of WordPress:


 {{{
 root at bdc07b68467e:/plugin# phpunit
 Installing...
 Running as single site... To run multisite, use -c
 tests/phpunit/multisite.xml
 Not running ajax tests. To execute these, use --group ajax.
 Not running ms-files tests. To execute these, use --group ms-files.
 Not running external-http tests. To execute these, use --group external-
 http.
 PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

 ..
 Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed
 in /root/.composer/vendor/phpunit/phpunit/src/Util/GlobalState.php:187
 Stack trace:
 #0 /root/.composer/vendor/phpunit/phpunit/src/Util/GlobalState.php(187):
 serialize(Array)
 #1 /root/.composer/vendor/phpunit/phpunit/src/Util/GlobalState.php(156):
 PHPUnit_Util_GlobalState::exportVariable(Array)
 #2 /root/.composer/vendor/phpunit/phpunit/src/Framework/TestCase.php(783):
 PHPUnit_Util_GlobalState::getGlobalsAsString()
 #3
 /root/.composer/vendor/phpunit/phpunit/src/Framework/TestSuite.php(733):
 PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
 #4
 /root/.composer/vendor/phpunit/phpunit/src/Framework/TestSuite.php(733):
 PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
 #5 /root/.composer/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(517):
 PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
 #6 /root/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(186):
 PHPUnit_TextUI_TestRunner->doRun(Obj in
 /root/.composer/vendor/phpunit/phpunit/src/Util/GlobalState.php on line
 187
 }}}


 Last succeed in CI
 2020-06-17 17:17
 https://travis-ci.org/github/yukihiko-
 shinoda/staticpress2019/builds/699221099

 First failed in CI
 2020-06-26 22:01
 https://travis-ci.org/github/yukihiko-
 shinoda/staticpress2019/builds/702342495

 I'm using @runInSeparateProcess annotation to test function including
 die().
 When I comment out all tests using @runInSeparateProcess,
 PHPUnit worked well.

 I'm perfectly following standard steps for PHPUnit:
 https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/

 Travis CI is standard environment to run PHPUnit for WordPress plugin.

 If you want to build environment to reproduce,
 This Docker Image may be your help:

 https://github.com/yukihiko-shinoda/dockerfile-phpunit-wordpress-plugin


 {{{
 docker build --build-arg PHP_VERSION=7.3 --build-arg
 WORDPRESS_VERSION=trunk .
 }}}


 VSCode integration also available:

 https://github.com/yukihiko-shinoda/docker-compose-phpunit-wordpress-
 plugin

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50482>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list