Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/controller.php

    r41139 r42343  
    1313    protected static $administrator;
    1414    protected static $subscriber;
    15     const YOUTUBE_VIDEO_ID = 'OQSNhk5ICTI';
     15    const YOUTUBE_VIDEO_ID   = 'OQSNhk5ICTI';
    1616    const INVALID_OEMBED_URL = 'https://www.notreallyanoembedprovider.com/watch?v=awesome-cat-video';
    1717
    1818    public static function wpSetUpBeforeClass( $factory ) {
    19         self::$subscriber = $factory->user->create( array(
    20             'role' => 'subscriber',
    21         ) );
    22         self::$editor = $factory->user->create( array(
    23             'role'       => 'editor',
    24             'user_email' => 'editor@example.com',
    25         ) );
    26         self::$administrator = $factory->user->create( array(
    27             'role'       => 'administrator',
    28             'user_email' => 'administrator@example.com',
    29         ) );
     19        self::$subscriber    = $factory->user->create(
     20            array(
     21                'role' => 'subscriber',
     22            )
     23        );
     24        self::$editor        = $factory->user->create(
     25            array(
     26                'role'       => 'editor',
     27                'user_email' => 'editor@example.com',
     28            )
     29        );
     30        self::$administrator = $factory->user->create(
     31            array(
     32                'role'       => 'administrator',
     33                'user_email' => 'administrator@example.com',
     34            )
     35        );
    3036    }
    3137
     
    8187                    'code' => 200,
    8288                ),
    83                 'body' => wp_json_encode(
     89                'body'     => wp_json_encode(
    8490                    array(
    8591                        'version'          => '1.0',
     
    116122
    117123    function test_oembed_create_xml() {
    118         $actual = _oembed_create_xml( array(
    119             'foo'  => 'bar',
    120             'bar'  => 'baz',
    121             'ping' => 'pong',
    122         ) );
     124        $actual = _oembed_create_xml(
     125            array(
     126                'foo'  => 'bar',
     127                'bar'  => 'baz',
     128                'ping' => 'pong',
     129            )
     130        );
    123131
    124132        $expected = '<oembed><foo>bar</foo><bar>baz</bar><ping>pong</ping></oembed>';
     
    126134        $this->assertStringEndsWith( $expected, trim( $actual ) );
    127135
    128         $actual = _oembed_create_xml( array(
    129             'foo'  => array(
    130                 'bar' => 'baz',
    131             ),
    132             'ping' => 'pong',
    133         ) );
     136        $actual = _oembed_create_xml(
     137            array(
     138                'foo'  => array(
     139                    'bar' => 'baz',
     140                ),
     141                'ping' => 'pong',
     142            )
     143        );
    134144
    135145        $expected = '<oembed><foo><bar>baz</bar></foo><ping>pong</ping></oembed>';
     
    137147        $this->assertStringEndsWith( $expected, trim( $actual ) );
    138148
    139         $actual = _oembed_create_xml( array(
    140             'foo'   => array(
    141                 'bar' => array(
    142                     'ping' => 'pong',
     149        $actual = _oembed_create_xml(
     150            array(
     151                'foo'   => array(
     152                    'bar' => array(
     153                        'ping' => 'pong',
     154                    ),
    143155                ),
    144             ),
    145             'hello' => 'world',
    146         ) );
     156                'hello' => 'world',
     157            )
     158        );
    147159
    148160        $expected = '<oembed><foo><bar><ping>pong</ping></bar></foo><hello>world</hello></oembed>';
     
    150162        $this->assertStringEndsWith( $expected, trim( $actual ) );
    151163
    152         $actual = _oembed_create_xml( array(
    153             array(
    154                 'foo' => array(
    155                     'bar',
     164        $actual = _oembed_create_xml(
     165            array(
     166                array(
     167                    'foo' => array(
     168                        'bar',
     169                    ),
    156170                ),
    157             ),
    158             'helloworld',
    159         ) );
     171                'helloworld',
     172            )
     173        );
    160174
    161175        $expected = '<oembed><oembed><foo><oembed>bar</oembed></foo></oembed><oembed>helloworld</oembed></oembed>';
     
    228242
    229243    function test_request_json() {
    230         $user = self::factory()->user->create_and_get( array(
    231             'display_name' => 'John Doe',
    232         ) );
    233         $post = self::factory()->post->create_and_get( array(
    234             'post_author' => $user->ID,
    235             'post_title'  => 'Hello World',
    236         ) );
     244        $user = self::factory()->user->create_and_get(
     245            array(
     246                'display_name' => 'John Doe',
     247            )
     248        );
     249        $post = self::factory()->post->create_and_get(
     250            array(
     251                'post_author' => $user->ID,
     252                'post_title'  => 'Hello World',
     253            )
     254        );
    237255
    238256        $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
     
    269287     */
    270288    function test_request_static_front_page() {
    271         $post = self::factory()->post->create_and_get( array(
    272             'post_title' => 'Front page',
    273             'post_type'  => 'page',
    274         ) );
     289        $post = self::factory()->post->create_and_get(
     290            array(
     291                'post_title' => 'Front page',
     292                'post_type'  => 'page',
     293            )
     294        );
    275295
    276296        update_option( 'show_on_front', 'page' );
     
    309329
    310330    function test_request_xml() {
    311         $user = self::factory()->user->create_and_get( array(
    312             'display_name' => 'John Doe',
    313         ) );
    314         $post = self::factory()->post->create_and_get( array(
    315             'post_author' => $user->ID,
    316             'post_title'  => 'Hello World',
    317         ) );
     331        $user = self::factory()->user->create_and_get(
     332            array(
     333                'display_name' => 'John Doe',
     334            )
     335        );
     336        $post = self::factory()->post->create_and_get(
     337            array(
     338                'post_author' => $user->ID,
     339                'post_title'  => 'Hello World',
     340            )
     341        );
    318342
    319343        $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
     
    355379        switch_to_blog( $child );
    356380
    357         $post = self::factory()->post->create_and_get( array(
    358             'post_title' => 'Hello Child Blog',
    359         ) );
     381        $post = self::factory()->post->create_and_get(
     382            array(
     383                'post_title' => 'Hello Child Blog',
     384            )
     385        );
    360386
    361387        $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
     
    373399
    374400    function test_rest_pre_serve_request() {
    375         $user = $this->factory()->user->create_and_get( array(
    376             'display_name' => 'John Doe',
    377         ) );
    378         $post = $this->factory()->post->create_and_get( array(
    379             'post_author' => $user->ID,
    380             'post_title'  => 'Hello World',
    381         ) );
     401        $user = $this->factory()->user->create_and_get(
     402            array(
     403                'display_name' => 'John Doe',
     404            )
     405        );
     406        $post = $this->factory()->post->create_and_get(
     407            array(
     408                'post_author' => $user->ID,
     409                'post_title'  => 'Hello World',
     410            )
     411        );
    382412
    383413        $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
     
    447477    public function test_proxy_without_permission() {
    448478        // Test without a login.
    449         $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' );
     479        $request  = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' );
    450480        $response = $this->server->dispatch( $request );
    451481
Note: See TracChangeset for help on using the changeset viewer.