2017-12-04 18:42:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tainacan\Tests;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic test case for api calls
|
|
|
|
* @author jacson
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class TAINACAN_UnitApiTestCase extends TAINACAN_UnitTestCase {
|
|
|
|
/**
|
|
|
|
* Test REST Server
|
|
|
|
* @var \WP_REST_Server
|
|
|
|
*/
|
|
|
|
protected $server;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default Tainacan Namespace
|
|
|
|
* @var string default '/tainacan/v2'
|
|
|
|
*/
|
2017-12-18 12:52:45 +00:00
|
|
|
protected $namespace = '/tainacan/v2';
|
|
|
|
|
|
|
|
protected $user_id;
|
2017-12-04 18:42:41 +00:00
|
|
|
|
|
|
|
public function setUp(){
|
|
|
|
parent::setUp();
|
2017-12-18 12:52:45 +00:00
|
|
|
|
|
|
|
// Create a Administrator user for test api with cookie authentication
|
|
|
|
$this->user_id = $this->factory->user->create(
|
|
|
|
array(
|
|
|
|
'role' => 'administrator'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Set that user as current user
|
|
|
|
wp_set_current_user( $this->user_id );
|
|
|
|
|
2017-12-04 18:42:41 +00:00
|
|
|
global $wp_rest_server;
|
|
|
|
$this->server = $wp_rest_server = new \WP_REST_Server;
|
2017-12-18 12:52:45 +00:00
|
|
|
|
2017-12-04 18:42:41 +00:00
|
|
|
do_action( 'rest_api_init' );
|
|
|
|
}
|
|
|
|
}
|