Ticket #39054: 39054.2.diff
File 39054.2.diff, 3.9 KB (added by , 8 years ago) |
---|
-
src/wp-includes/rest-api.php
1066 1066 if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) { 1067 1067 if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) { 1068 1068 /* translators: 1: parameter, 2: minimum number */ 1069 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (exclusive)' ), $param, $args['minimum'] ) );1069 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] ) ); 1070 1070 } elseif ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) { 1071 1071 /* translators: 1: parameter, 2: minimum number */ 1072 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (inclusive)' ), $param, $args['minimum'] ) );1072 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] ) ); 1073 1073 } 1074 1074 } elseif ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) { 1075 1075 if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) { 1076 1076 /* translators: 1: parameter, 2: maximum number */ 1077 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (exclusive)' ), $param, $args['maximum'] ) );1077 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] ) ); 1078 1078 } elseif ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) { 1079 1079 /* translators: 1: parameter, 2: maximum number */ 1080 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than %2$d (inclusive)' ), $param, $args['maximum'] ) );1080 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] ) ); 1081 1081 } 1082 1082 } elseif ( isset( $args['maximum'] ) && isset( $args['minimum'] ) ) { 1083 1083 if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) { -
tests/phpunit/tests/rest-api/rest-categories-controller.php
186 186 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 187 187 $data = $response->get_data(); 188 188 $first_error = array_shift( $data['data']['params'] ); 189 $this->assertContains( 'page must be greater than 1 (inclusive)', $first_error );189 $this->assertContains( 'page must be greater than or equal to 1', $first_error ); 190 190 } 191 191 192 192 public function test_get_items_include_query() { -
tests/phpunit/tests/rest-api/rest-schema-validation.php
19 19 ); 20 20 $this->assertTrue( rest_validate_value_from_schema( 1, $schema ) ); 21 21 $this->assertTrue( rest_validate_value_from_schema( 2, $schema ) ); 22 $this->assertWPError( rest_validate_value_from_schema( 0.9, $schema ) ); 22 23 $this->assertWPError( rest_validate_value_from_schema( 3, $schema ) ); 23 24 $this->assertWPError( rest_validate_value_from_schema( true, $schema ) ); 24 25 } … … 31 32 ); 32 33 $this->assertTrue( rest_validate_value_from_schema( 1, $schema ) ); 33 34 $this->assertTrue( rest_validate_value_from_schema( 2, $schema ) ); 35 $this->assertWPError( rest_validate_value_from_schema( 0, $schema ) ); 34 36 $this->assertWPError( rest_validate_value_from_schema( 3, $schema ) ); 35 37 $this->assertWPError( rest_validate_value_from_schema( 1.1, $schema ) ); 36 38 }