Changeset 39594
- Timestamp:
- 12/13/2016 03:33:14 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-request.php
r39563 r39594 670 670 } 671 671 672 $params = json_decode( $this->get_body(), true ); 672 $body = $this->get_body(); 673 if ( empty( $body ) ) { 674 return true; 675 } 676 677 $params = json_decode( $body, true ); 673 678 674 679 /* -
trunk/tests/phpunit/tests/rest-api/rest-request.php
r39563 r39594 11 11 */ 12 12 class Tests_REST_Request extends WP_UnitTestCase { 13 public $request; 14 13 15 public function setUp() { 14 16 parent::setUp(); … … 449 451 $data = $valid->get_error_data(); 450 452 $this->assertEquals( JSON_ERROR_SYNTAX, $data['json_error_code'] ); 453 } 454 455 456 public function test_has_valid_params_empty_json_no_error() { 457 if ( version_compare( PHP_VERSION, '5.3', '<' ) ) { 458 return $this->markTestSkipped( 'JSON validation is only available for PHP 5.3+' ); 459 } 460 461 $this->request->set_header( 'Content-Type', 'application/json' ); 462 $this->request->set_body( '' ); 463 464 $valid = $this->request->has_valid_params(); 465 $this->assertNotWPError( $valid ); 451 466 } 452 467
Note: See TracChangeset
for help on using the changeset viewer.