Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/wporg-plugin-api.php
- Timestamp:
- 12/19/2017 04:22:37 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/wporg-plugin-api.php
r5841 r6287 9 9 class Tests_Plugins_API extends WP_UnitTestCase { 10 10 11 public $api_endpoint_1_0 = 'http://api.wordpress.org/plugins/info/1.0/';12 public $api_endpoint_1_1 = 'http://api.wordpress.org/plugins/info/1.1/';13 public $api_endpoint_plugin_php = 'http://api.wordpress.org/plugins/info/1.0/jetpack.php';14 public $api_endpoint_plugin_xml = 'http://api.wordpress.org/plugins/info/1.0/jetpack.xml';11 public $api_endpoint_1_0 = 'http://api.wordpress.org/plugins/info/1.0/'; 12 public $api_endpoint_1_1 = 'http://api.wordpress.org/plugins/info/1.1/'; 13 public $api_endpoint_plugin_php = 'http://api.wordpress.org/plugins/info/1.0/jetpack.php'; 14 public $api_endpoint_plugin_xml = 'http://api.wordpress.org/plugins/info/1.0/jetpack.xml'; 15 15 public $api_endpoint_plugin_json = 'http://api.wordpress.org/plugins/info/1.0/jetpack.json'; 16 16 17 public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end17 public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end 18 18 public $require_tested_value = true; 19 19 … … 42 42 'active_installs' => true, 43 43 'contributors' => true, 44 'donate_link' => true,44 'donate_link' => true, 45 45 ); 46 46 … … 79 79 80 80 function test_wporg_plugin_api_serialize_php() { 81 $response = $this->api_remote_post( $this->api_endpoint_1_0, 'plugin_information', array( 'slug' => 'jetpack', 'fields' => $this->fields ) ); 82 $plugins = maybe_unserialize( wp_remote_retrieve_body( $response ) ); 81 $response = $this->api_remote_post( $this->api_endpoint_1_0, 'plugin_information', array( 82 'slug' => 'jetpack', 83 'fields' => $this->fields, 84 ) ); 85 $plugins = maybe_unserialize( wp_remote_retrieve_body( $response ) ); 83 86 84 87 $this->_check_response_attributes( $plugins ); … … 86 89 87 90 function test_wporg_plugin_api_serialize_php_get() { 88 $url = add_query_arg( 'fields', implode( ',' , array_keys( $this->fields ) ), $this->api_endpoint_plugin_php );91 $url = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_php ); 89 92 $response = $this->api_remote_get( $url ); 90 93 $plugins = maybe_unserialize( wp_remote_retrieve_body( $response ) ); … … 94 97 95 98 function test_wporg_plugin_api_xml() { 96 $url = add_query_arg( 'fields', implode( ',' , array_keys( $this->fields ) ), $this->api_endpoint_plugin_xml );99 $url = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_xml ); 97 100 $response = $this->api_remote_get( $url ); 98 101 $plugins = wp_remote_retrieve_body( $response ); … … 104 107 105 108 function test_wporg_plugin_api_json() { 106 $url = add_query_arg( 'fields', implode( ',' , array_keys( $this->fields ) ), $this->api_endpoint_plugin_json );109 $url = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_json ); 107 110 $response = $this->api_remote_get( $url ); 108 111 $plugins = (object) json_decode( wp_remote_retrieve_body( $response ), true ); … … 116 119 'body' => array( 117 120 'action' => 'plugin_information', 118 'request' => (object) array( 'slug' => 'jetpack', 'fields' => $this->fields ), 121 'request' => (object) array( 122 'slug' => 'jetpack', 123 'fields' => $this->fields, 124 ), 119 125 ), 120 126 'headers' => array( 'Host', 'api.wordpress.org' ), 121 122 127 ) ); 123 128 … … 127 132 128 133 function test_plugins_api_function_action_plugin_information() { 129 $plugins = plugins_api( 'plugin_information', array( 'slug' => 'jetpack', 'fields' => $this->fields ) ); 134 $plugins = plugins_api( 'plugin_information', array( 135 'slug' => 'jetpack', 136 'fields' => $this->fields, 137 ) ); 130 138 $this->_check_response_attributes( $plugins ); 131 139 } … … 145 153 146 154 // If search term exactly matches a slug, it should be returned first. 147 $plugins = plugins_api( 'query_plugins', array( 'search' => $slug ) );155 $plugins = plugins_api( 'query_plugins', array( 'search' => $slug ) ); 148 156 $this->assertEquals( $plugins->plugins[0]->slug, $slug ); 149 157 } … … 152 160 function test_plugins_api_function_action_query_plugins_tag() { 153 161 $tag = 'widget'; 154 $plugins = plugins_api( 'query_plugins', array( 'tag' => $tag, 'fields' => $this->fields ) ); 162 $plugins = plugins_api( 'query_plugins', array( 163 'tag' => $tag, 164 'fields' => $this->fields, 165 ) ); 155 166 156 167 foreach ( $plugins->plugins as $plugin ) { … … 163 174 function test_plugins_api_function_action_query_plugins_author() { 164 175 $author = 'wordpressdotorg'; 165 $plugins = plugins_api( 'query_plugins', array( 'author' => $author, 'fields' => $this->fields ) ); 176 $plugins = plugins_api( 'query_plugins', array( 177 'author' => $author, 178 'fields' => $this->fields, 179 ) ); 166 180 167 181 foreach ( $plugins->plugins as $plugin ) { … … 173 187 // Favorites. 174 188 function test_plugins_api_function_action_query_plugins_user() { 175 $plugins = plugins_api( 'query_plugins', array( 'user' => 'markjaquith', 'fields' => $this->fields ) ); 189 $plugins = plugins_api( 'query_plugins', array( 190 'user' => 'markjaquith', 191 'fields' => $this->fields, 192 ) ); 176 193 $this->_check_response_plugin_query( $plugins, 1 ); 177 194 } 178 195 179 196 function test_plugins_api_function_action_query_plugins_browse() { 180 $plugins = plugins_api( 'query_plugins', array( 'browse' => 'popular', 'fields' => $this->fields ) ); 197 $plugins = plugins_api( 'query_plugins', array( 198 'browse' => 'popular', 199 'fields' => $this->fields, 200 ) ); 181 201 $this->_check_response_plugin_query( $plugins ); 182 202 } 183 203 184 204 function test_plugins_api_function_action_query_plugins_installed_plugins() { 185 $plugins = plugins_api( 'query_plugins', array( 'browse' => 'recommended', 'installed_plugins' => array( 'jetpack' ), 'fields' => $this->fields ) ); 205 $plugins = plugins_api( 'query_plugins', array( 206 'browse' => 'recommended', 207 'installed_plugins' => array( 'jetpack' ), 208 'fields' => $this->fields, 209 ) ); 186 210 $this->_check_response_plugin_query( $plugins, 1 ); 187 211 } … … 189 213 function test_plugins_api_function_action_query_plugins_local() { 190 214 // Not yet implemented. Shouldn't change the structure of the response though. 191 $plugins = plugins_api( 'query_plugins', array( 'local' => 'hello', 'fields' => $this->fields ) ); 215 $plugins = plugins_api( 'query_plugins', array( 216 'local' => 'hello', 217 'fields' => $this->fields, 218 ) ); 192 219 $this->_check_response_plugin_query( $plugins, 1 ); 193 220 } … … 321 348 class Tests_Plugins_API_Old extends Tests_Plugins_API { 322 349 public $user_agent = 'WordPress/4.7'; // Tell the API to use the old back-end 350 323 351 public $require_tested_value = false; // Old API omits 'tested' if its value is empty 324 325 326 352 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)