Make WordPress Core

Changeset 49007


Ignore:
Timestamp:
09/20/2020 12:55:07 AM (6 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/tests/phpunit/tests/rest-api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-schema-sanitization.php

    r48937 r49007  
    361361         */
    362362        public function test_format_validation_is_applied_if_missing_type() {
    363                 $this->expectException( 'PHPUnit_Framework_Error_Notice' ); // For the undefined index.
     363                if ( PHP_VERSION_ID >= 80000 ) {
     364                        $this->expectException( 'PHPUnit_Framework_Error_Warning' ); // For the undefined index.
     365                } else {
     366                        $this->expectException( 'PHPUnit_Framework_Error_Notice' );
     367                }
     368
    364369                $this->setExpectedIncorrectUsage( 'rest_sanitize_value_from_schema' );
    365370
  • trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php

    r48937 r49007  
    157157         */
    158158        public function test_format_validation_is_applied_if_missing_type() {
    159                 $this->expectException( 'PHPUnit_Framework_Error_Notice' ); // For the undefined index.
     159                if ( PHP_VERSION_ID >= 80000 ) {
     160                        $this->expectException( 'PHPUnit_Framework_Error_Warning' ); // For the undefined index.
     161                } else {
     162                        $this->expectException( 'PHPUnit_Framework_Error_Notice' );
     163                }
     164
    160165                $this->setExpectedIncorrectUsage( 'rest_validate_value_from_schema' );
    161166
Note: See TracChangeset for help on using the changeset viewer.