Sunday, September 4, 2022
HomeWordPress Developmentplugin growth - PHPUnit Ajax Serialization of 'Closure' isn't allowed

plugin growth – PHPUnit Ajax Serialization of ‘Closure’ isn’t allowed


Making an attempt to arrange a easy AJAX unit check and I get this error.

Serialization of ‘Closure’ isn’t allowed

Issues I put in

  • wp scaffold plugin testplugin (can also use wp scaffold plugin-tests testplugin for current plugins)
  • composer require phpunit/phpunit ^9 --dev
  • composer require yoast/phpunit-polyfills --dev

That is the precise check class I used to be attempting…

/**
 * Check circumstances for AJAX capabilities
 *
 * @group ajax
 * @runTestsInSeparateProcesses
 */
class AjaxTest extends WP_Ajax_UnitTestCase {

    public operate setUp(): void
    {
        guardian::setUp();
    }

    public operate testIsTrue(): void
    {
        $this->assertTrue( true );
    }
}

Full output

./vendor/bin/phpunit --group=ajax --verbose --debug
Putting in...
Working as single web site... To run multisite, use -c assessments/phpunit/multisite.xml
Not working ajax assessments. To execute these, use --group ajax.
Not working ms-files assessments. To execute these, use --group ms-files.
Not working external-http assessments. To execute these, use --group external-http.
PHPUnit 9.5.24 #StandWithUkraine

Runtime:       PHP 8.1.9
Configuration: /var/www/check/wp-content/plugins/testplugin/phpunit.xml.dist

Serialization of 'Closure' isn't allowed

EDIT: Realized that in response to the WP/PHPUnit compatability matrix, PHP 8.1 isn’t supported. So I attempted once more with PHP 8.0. Nonetheless, I get the identical error.

./vendor/bin/phpunit --group=ajax --debug --verbose

Putting in...
Working as single web site... To run multisite, use -c assessments/phpunit/multisite.xml
Not working ajax assessments. To execute these, use --group ajax.
Not working ms-files assessments. To execute these, use --group ms-files.
Not working external-http assessments. To execute these, use --group external-http.
PHPUnit 9.5.24 #StandWithUkraine

Runtime:       PHP 8.0.22
Configuration: /var/www/check/wp-content/plugins/testplugin/phpunit.xml.dist

Serialization of 'Closure' isn't allowed

EDIT 2: Additionally seen Not working ajax assessments. To execute these, use --group ajax. as a result of I used to be utilizing --group=ajax and never --group ajax. So I attempted this, however nonetheless get the identical error.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments