From 83c6728175eda80ed75698c9d7268fe8c8f55745 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Sat, 24 May 2014 18:29:28 +1000 Subject: [PATCH 1/2] Move server class load to base --- plugin.php | 3 +-- tests/test_json_server.php | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/plugin.php b/plugin.php index f658155bfe..5f85de9ef1 100644 --- a/plugin.php +++ b/plugin.php @@ -23,6 +23,7 @@ include_once( dirname( __FILE__ ) . '/lib/class-wp-json-datetime.php' ); include_once( dirname( __FILE__ ) . '/lib/class-wp-json-responsehandler.php' ); +include_once( dirname( __FILE__ ) . '/lib/class-wp-json-server.php' ); include_once( dirname( __FILE__ ) . '/lib/class-wp-json-responseinterface.php' ); include_once( dirname( __FILE__ ) . '/lib/class-wp-json-response.php' ); @@ -113,8 +114,6 @@ function json_api_loaded() { if ( empty( $GLOBALS['wp']->query_vars['json_route'] ) ) return; - include_once( dirname( __FILE__ ) . '/lib/class-wp-json-server.php' ); - /** * Whether this is a XMLRPC Request * diff --git a/tests/test_json_server.php b/tests/test_json_server.php index 702960062f..944e95fd6d 100644 --- a/tests/test_json_server.php +++ b/tests/test_json_server.php @@ -24,8 +24,6 @@ function setUp() { parent::setUp(); - include_once( plugin_dir_path( dirname( __FILE__ ) ) . 'lib/class-wp-json-server.php' ); - // Allow for a plugin to insert a different class to handle requests. $wp_json_server_class = apply_filters('wp_json_server_class', 'WP_JSON_Server'); $wp_json_server = new $wp_json_server_class; From 67a1b876c10bccc61574721f43e0173232233afc Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Sat, 24 May 2014 18:32:47 +1000 Subject: [PATCH 2/2] Check plugin location correctly --- tests/bootstrap.php | 2 +- tests/test_json_plugin.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 42cd9587a1..5d8361551f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,7 +8,7 @@ // Activates this plugin in WordPress so it can be tested. $GLOBALS['wp_tests_options'] = array( - 'active_plugins' => array( 'WP-API/plugin.php' ), + 'active_plugins' => array( basename( dirname( dirname( __FILE__ ) ) ) . '/plugin.php' ), ); // If the develop repo location is defined (as WP_DEVELOP_DIR), use that diff --git a/tests/test_json_plugin.php b/tests/test_json_plugin.php index b60eb98377..d63d23c640 100644 --- a/tests/test_json_plugin.php +++ b/tests/test_json_plugin.php @@ -15,7 +15,8 @@ class WP_Test_JSON_Plugin extends WP_UnitTestCase { * The plugin should be installed and activated. */ function test_plugin_activated() { - $this->assertTrue( is_plugin_active( 'WP-API/plugin.php' ) ); + $directory = basename( dirname( dirname( __FILE__ ) ) ); + $this->assertTrue( is_plugin_active( $directory . '/plugin.php' ) ); } /**