Make WordPress Core


Ignore:
Timestamp:
09/26/2021 03:27:10 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Update the Services_JSON test for PHPUnit 9.5.10/8.5.21+.

Since PHPUnit 9.5.10 and 8.5.21, PHP deprecations are no longer converted to exceptions by default (convertDeprecationsToExceptions="true" can be configured to enable this).

Reference: Do not convert PHP deprecations to exceptions by default; PHPUnit 9.5.10 changelog.

With this change, the test for the Services_JSON compat class started failing:

There was 1 failure:

1) Tests_Compat_jsonEncodeDecode::test_json_encode_decode
Failed asserting that exception of type "PHPUnit\Framework\Error\Deprecated" is thrown.

This converts the native PHPUnit ::expectDeprecation() method call in the test to a set of individual WP-specific ::setExpectedDeprecated() method calls in order to not depend on PHPUnit behavior that is no longer the default.

Additionally, this commit includes support for catching deprecation notices from _deprecated_file() function calls to the WP_UnitTestCase_Base::expectDeprecated() method.

Follow-up to [46205], [46625], [48996], [51563], [51852], [51871].

Props jrf, netweb, SergeyBiryukov.
See #54183, #54029, #53363.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r51831 r51872  
    504504        add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
    505505        add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) );
     506        add_action( 'deprecated_file_included', array( $this, 'deprecated_function_run' ) );
    506507        add_action( 'deprecated_hook_run', array( $this, 'deprecated_function_run' ) );
    507508        add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) );
    508509        add_action( 'deprecated_function_trigger_error', '__return_false' );
    509510        add_action( 'deprecated_argument_trigger_error', '__return_false' );
     511        add_action( 'deprecated_file_trigger_error', '__return_false' );
    510512        add_action( 'deprecated_hook_trigger_error', '__return_false' );
    511513        add_action( 'doing_it_wrong_trigger_error', '__return_false' );
Note: See TracChangeset for help on using the changeset viewer.