Automattic\WP\Cron_Control\Tests\REST_API_Tests::test_get_items PHP Метод

test_get_items() публичный Метод

Test that list endpoint returns expected format
public test_get_items ( )
    public function test_get_items()
    {
        $ev = Utils::create_test_event();
        // Don't test internal events with this test
        $internal_events = array('a8c_cron_control_force_publish_missed_schedules', 'a8c_cron_control_confirm_scheduled_posts', 'a8c_cron_control_clean_legacy_data', 'a8c_cron_control_purge_completed_events');
        foreach ($internal_events as $internal_event) {
            wp_clear_scheduled_hook($internal_event);
        }
        $request = new \WP_REST_Request('POST', '/' . \Automattic\WP\Cron_Control\REST_API::API_NAMESPACE . '/' . \Automattic\WP\Cron_Control\REST_API::ENDPOINT_LIST);
        $request->set_body(wp_json_encode(array('secret' => \WP_CRON_CONTROL_SECRET)));
        $request->set_header('content-type', 'application/json');
        $response = $this->server->dispatch($request);
        $data = $response->get_data();
        $this->assertResponseStatus(200, $response);
        $this->assertArrayHasKey('events', $data);
        $this->assertArrayHasKey('endpoint', $data);
        $this->assertResponseData(array('events' => array(array('timestamp' => $ev['timestamp'], 'action' => md5($ev['action']), 'instance' => md5(maybe_serialize($ev['args'])))), 'endpoint' => get_rest_url(null, \Automattic\WP\Cron_Control\REST_API::API_NAMESPACE . '/' . \Automattic\WP\Cron_Control\REST_API::ENDPOINT_RUN)), $response);
    }