mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-03 14:17:06 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -13,31 +13,33 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->request = new WP_REST_Request( 'GET', '/wp/v2/testroute', array(
|
||||
'args' => array(
|
||||
'someinteger' => array(
|
||||
'type' => 'integer',
|
||||
$this->request = new WP_REST_Request(
|
||||
'GET', '/wp/v2/testroute', array(
|
||||
'args' => array(
|
||||
'someinteger' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'someboolean' => array(
|
||||
'type' => 'boolean',
|
||||
),
|
||||
'somestring' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'someenum' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'a' ),
|
||||
),
|
||||
'somedate' => array(
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
),
|
||||
'someemail' => array(
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
),
|
||||
),
|
||||
'someboolean' => array(
|
||||
'type' => 'boolean',
|
||||
),
|
||||
'somestring' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'someenum' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'a' ),
|
||||
),
|
||||
'somedate' => array(
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
),
|
||||
'someemail' => array(
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
),
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function test_validate_schema_type_integer() {
|
||||
@@ -87,28 +89,36 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
);
|
||||
|
||||
// Check sanitize testing.
|
||||
$this->assertEquals( false,
|
||||
$this->assertEquals(
|
||||
false,
|
||||
rest_sanitize_request_arg( 'false', $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( false,
|
||||
$this->assertEquals(
|
||||
false,
|
||||
rest_sanitize_request_arg( '0', $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( false,
|
||||
$this->assertEquals(
|
||||
false,
|
||||
rest_sanitize_request_arg( 0, $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( false,
|
||||
$this->assertEquals(
|
||||
false,
|
||||
rest_sanitize_request_arg( 'FALSE', $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( true,
|
||||
$this->assertEquals(
|
||||
true,
|
||||
rest_sanitize_request_arg( 'true', $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( true,
|
||||
$this->assertEquals(
|
||||
true,
|
||||
rest_sanitize_request_arg( '1', $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( true,
|
||||
$this->assertEquals(
|
||||
true,
|
||||
rest_sanitize_request_arg( 1, $this->request, 'someboolean' )
|
||||
);
|
||||
$this->assertEquals( true,
|
||||
$this->assertEquals(
|
||||
true,
|
||||
rest_sanitize_request_arg( 'TRUE', $this->request, 'someboolean' )
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user