WordPress.org

Making WordPress.org


Ignore:
Timestamp:
12/19/2017 04:22:37 PM (19 months ago)
Author:
obenland
Message:

PLugins: Clean up formatting with phpcbf

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  
    99class Tests_Plugins_API extends WP_UnitTestCase {
    1010
    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';
    1515    public $api_endpoint_plugin_json = 'http://api.wordpress.org/plugins/info/1.0/jetpack.json';
    1616
    17     public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end
     17    public $user_agent           = 'WordPress/4.8'; // Tell the API to use the v3 back-end
    1818    public $require_tested_value = true;
    1919
     
    4242        'active_installs'   => true,
    4343        'contributors'      => true,
    44         'donate_link'       => true,
     44        'donate_link'       => true,
    4545    );
    4646
     
    7979
    8080    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 ) );
    8386
    8487        $this->_check_response_attributes( $plugins );
     
    8689
    8790    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 );
    8992        $response = $this->api_remote_get( $url );
    9093        $plugins  = maybe_unserialize( wp_remote_retrieve_body( $response ) );
     
    9497
    9598    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 );
    97100        $response = $this->api_remote_get( $url );
    98101        $plugins  = wp_remote_retrieve_body( $response );
     
    104107
    105108    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 );
    107110        $response = $this->api_remote_get( $url );
    108111        $plugins  = (object) json_decode( wp_remote_retrieve_body( $response ), true );
     
    116119            'body'    => array(
    117120                'action'  => 'plugin_information',
    118                 'request' => (object) array( 'slug' => 'jetpack', 'fields' => $this->fields ),
     121                'request' => (object) array(
     122                    'slug'   => 'jetpack',
     123                    'fields' => $this->fields,
     124                ),
    119125            ),
    120126            'headers' => array( 'Host', 'api.wordpress.org' ),
    121 
    122127        ) );
    123128
     
    127132
    128133    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        ) );
    130138        $this->_check_response_attributes( $plugins );
    131139    }
     
    145153
    146154        // 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 ) );
    148156        $this->assertEquals( $plugins->plugins[0]->slug, $slug );
    149157    }
     
    152160    function test_plugins_api_function_action_query_plugins_tag() {
    153161        $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        ) );
    155166
    156167        foreach ( $plugins->plugins as $plugin ) {
     
    163174    function test_plugins_api_function_action_query_plugins_author() {
    164175        $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        ) );
    166180
    167181        foreach ( $plugins->plugins as $plugin ) {
     
    173187    // Favorites.
    174188    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        ) );
    176193        $this->_check_response_plugin_query( $plugins, 1 );
    177194    }
    178195
    179196    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        ) );
    181201        $this->_check_response_plugin_query( $plugins );
    182202    }
    183203
    184204    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        ) );
    186210        $this->_check_response_plugin_query( $plugins, 1 );
    187211    }
     
    189213    function test_plugins_api_function_action_query_plugins_local() {
    190214        // 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        ) );
    192219        $this->_check_response_plugin_query( $plugins, 1 );
    193220    }
     
    321348class Tests_Plugins_API_Old extends Tests_Plugins_API {
    322349    public $user_agent = 'WordPress/4.7'; // Tell the API to use the old back-end
     350
    323351    public $require_tested_value = false; // Old API omits 'tested' if its value is empty
    324 
    325 
    326352}
Note: See TracChangeset for help on using the changeset viewer.