Tests: Fix the failures in REST API format keyword validation tests on PHP 8.

The tests ensure that `rest_sanitize_value_from_schema()` and `rest_validate_value_from_schema()` throw an "undefined offset" notice when the required `type` schema keyword is not passed.

In PHP 8, that notice is now a warning, so the tests need to be adjusted accordingly.

Follow-up to [48300], [48993].

See #50913.

git-svn-id: https://develop.svn.wordpress.org/trunk@49007 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-09-20 00:55:07 +00:00
parent 835e9c48a4
commit cdd15a8f77
2 changed files with 12 additions and 2 deletions

View File

@ -360,7 +360,12 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase {
* @ticket 50189
*/
public function test_format_validation_is_applied_if_missing_type() {
$this->expectException( 'PHPUnit_Framework_Error_Notice' ); // For the undefined index.
if ( PHP_VERSION_ID >= 80000 ) {
$this->expectException( 'PHPUnit_Framework_Error_Warning' ); // For the undefined index.
} else {
$this->expectException( 'PHPUnit_Framework_Error_Notice' );
}
$this->setExpectedIncorrectUsage( 'rest_sanitize_value_from_schema' );
$schema = array( 'format' => 'hex-color' );

View File

@ -156,7 +156,12 @@ class WP_Test_REST_Schema_Validation extends WP_UnitTestCase {
* @ticket 50189
*/
public function test_format_validation_is_applied_if_missing_type() {
$this->expectException( 'PHPUnit_Framework_Error_Notice' ); // For the undefined index.
if ( PHP_VERSION_ID >= 80000 ) {
$this->expectException( 'PHPUnit_Framework_Error_Warning' ); // For the undefined index.
} else {
$this->expectException( 'PHPUnit_Framework_Error_Notice' );
}
$this->setExpectedIncorrectUsage( 'rest_validate_value_from_schema' );
$schema = array( 'format' => 'email' );