[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
Mon Aug 17 22:25:29 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:  reopened
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:  5.5
 Severity:  critical          |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------

Comment (by thomasplevy):

 @yshinoda

 I've run into a similar problems in some of my WP plugin test cases (built
 off the wp develop unit testing lib) when running tests with
 `@runInSeparateProcess`

 This error is only presenting itself for me when I run tests against WP
 5.5. On 5.4 or lower it doesn't have any issues. I haven yet to determine
 what's changed to cause this but for my issues I've been able to resolve
 this by adding an additional annotation to my `@runInSeparateProcess`
 tests which disables the global state preservation which happens when
 running tests in a separate process:

 `@preserveGlobalState disabled`

 I came to this "solution" via the following sources:

 https://stackoverflow.com/a/14514753/400568

 And instead of overwriting the `run()` method I decided to add an
 annotation to the specific test cases:
 https://phpunit.readthedocs.io/en/9.2/annotations.html?highlight=preserve%20global%20state#preserveglobalstate

 I can't quite figure out what's causing this from 5.5, as I said, but
 wanted to share what's helped me out in the meantime.

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


More information about the wp-trac mailing list