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/rest-api/rest-controller.php

    r39161 r42343  
    1414    public function setUp() {
    1515        parent::setUp();
    16         $this->request = new WP_REST_Request( 'GET', '/wp/v2/testroute', array(
    17             'args'     => array(
    18                 'someinteger'     => array(
    19                     'type'        => 'integer',
     16        $this->request = new WP_REST_Request(
     17            'GET', '/wp/v2/testroute', array(
     18                'args' => array(
     19                    'someinteger' => array(
     20                        'type' => 'integer',
     21                    ),
     22                    'someboolean' => array(
     23                        'type' => 'boolean',
     24                    ),
     25                    'somestring'  => array(
     26                        'type' => 'string',
     27                    ),
     28                    'someenum'    => array(
     29                        'type' => 'string',
     30                        'enum' => array( 'a' ),
     31                    ),
     32                    'somedate'    => array(
     33                        'type'   => 'string',
     34                        'format' => 'date-time',
     35                    ),
     36                    'someemail'   => array(
     37                        'type'   => 'string',
     38                        'format' => 'email',
     39                    ),
    2040                ),
    21                 'someboolean'     => array(
    22                     'type'        => 'boolean',
    23                 ),
    24                 'somestring'      => array(
    25                     'type'        => 'string',
    26                 ),
    27                 'someenum'        => array(
    28                     'type'        => 'string',
    29                     'enum'        => array( 'a' ),
    30                 ),
    31                 'somedate'        => array(
    32                     'type'        => 'string',
    33                     'format'      => 'date-time',
    34                 ),
    35                 'someemail'       => array(
    36                     'type'        => 'string',
    37                     'format'      => 'email',
    38                 ),
    39             ),
    40         ));
     41            )
     42        );
    4143    }
    4244
     
    8890
    8991        // Check sanitize testing.
    90         $this->assertEquals( false,
     92        $this->assertEquals(
     93            false,
    9194            rest_sanitize_request_arg( 'false', $this->request, 'someboolean' )
    9295        );
    93         $this->assertEquals( false,
     96        $this->assertEquals(
     97            false,
    9498            rest_sanitize_request_arg( '0', $this->request, 'someboolean' )
    9599        );
    96         $this->assertEquals( false,
     100        $this->assertEquals(
     101            false,
    97102            rest_sanitize_request_arg( 0, $this->request, 'someboolean' )
    98103        );
    99         $this->assertEquals( false,
     104        $this->assertEquals(
     105            false,
    100106            rest_sanitize_request_arg( 'FALSE', $this->request, 'someboolean' )
    101107        );
    102         $this->assertEquals( true,
     108        $this->assertEquals(
     109            true,
    103110            rest_sanitize_request_arg( 'true', $this->request, 'someboolean' )
    104111        );
    105         $this->assertEquals( true,
     112        $this->assertEquals(
     113            true,
    106114            rest_sanitize_request_arg( '1', $this->request, 'someboolean' )
    107115        );
    108         $this->assertEquals( true,
     116        $this->assertEquals(
     117            true,
    109118            rest_sanitize_request_arg( 1, $this->request, 'someboolean' )
    110119        );
    111         $this->assertEquals( true,
     120        $this->assertEquals(
     121            true,
    112122            rest_sanitize_request_arg( 'TRUE', $this->request, 'someboolean' )
    113123        );
Note: See TracChangeset for help on using the changeset viewer.