[wp-trac] [WordPress Trac] #50366: WordPress rest_api_init action doesn't work in PHPUnit tests
WordPress Trac
noreply at wordpress.org
Thu Jun 11 07:44:23 UTC 2020
#50366: WordPress rest_api_init action doesn't work in PHPUnit tests
-------------------------------+------------------------------
Reporter: skarabeq | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 5.4.2
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Comment (by skarabeq):
Hi, @ocean90
No, I have run tests without plugins and I have removed all other methods.
I have run the following test:
{{{#!php
<?php
class WordPressTestExample extends \WP_UnitTestCase
{
/**
* Test REST Server
*
* @var \WP_REST_Server
*/
private $server;
/**
* Initialize WP API rest.
*/
public function setUp()
{
parent::setUp();
global $wp_rest_server;
$wp_rest_server = new \WP_REST_Server;
$this->server = $wp_rest_server;
do_action('rest_api_init');
}
/**
* Destruction API WP rest server.
*/
public function tearDown()
{
parent::tearDown();
global $wp_rest_server;
$wp_rest_server = null;
}
/**
* Dummy test.
*/
public function testAPI()
{
$this->assertTrue(true);
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50366#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list