add a base class for api test cases

This commit is contained in:
Jacson Passold 2017-12-04 16:42:41 -02:00
parent ffd2d4e2fa
commit 3607d99181
2 changed files with 38 additions and 0 deletions

View File

@ -32,4 +32,5 @@ require_once(__DIR__ . '/factories/class-tainacan-entity-factory.php');
require_once(__DIR__ . '/factories/class-tainacan-field-factory.php');
require_once(__DIR__ . '/factories/class-tainacan-filter-factory.php');
require_once(__DIR__ . '/tainacan-unit-test-case.php');
require_once(__DIR__ . '/tainacan-unit-api-test-case.php');

View File

@ -0,0 +1,37 @@
<?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'
*/
protected $namespaced_route = '/tainacan/v2';
public function setUp(){
parent::setUp();
global $wp_rest_server;
$this->server = $wp_rest_server = new \WP_REST_Server;
do_action( 'rest_api_init' );
//add_action( 'init', array($this, 'activate_plugin_via_php' ) );
}
public function activate_plugin_via_php() {
$active_plugins = get_option( 'active_plugins' );
array_push($active_plugins, 'tainacan/tainacan.php'); /* Here just replace unyson plugin directory and plugin file*/
update_option( 'active_plugins', $active_plugins );
}
}