Make WordPress Core


Ignore:
Timestamp:
07/03/2022 05:28:12 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Docs: Add @since tags for _doing_it_wrong() and deprecation notice handlers in the PHPUnit test suite.

This affects methods in the WP_UnitTestCase_Base class:

  • ::expectDeprecated()
  • ::expectedDeprecated()
  • ::setExpectedException()
  • ::deprecated_function_run()
  • ::doing_it_wrong_run()

Follow-up to [25402], [25408], [25785], [37861], [40536], [40539], [40872], [51872], [53637].

See #55652, #55646.

File:
1 edited

Legend:

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

    r53637 r53638  
    488488    /**
    489489     * Sets up the expectations for testing a deprecated call.
     490     *
     491     * @since 3.7.0
    490492     */
    491493    public function expectDeprecated() {
     
    534536     *
    535537     * The DocBlock should contain `@expectedDeprecated` to trigger this.
     538     *
     539     * @since 3.7.0
     540     * @since 6.1.0 Includes the actual unexpected `_doing_it_wrong()` message
     541     *              or deprecation notice in the output if one is encountered.
    536542     */
    537543    public function expectedDeprecated() {
     
    544550
    545551        foreach ( $not_caught_deprecated as $not_caught ) {
    546             $errors[] = "Failed to assert that $not_caught triggered a deprecation notice";
     552            $errors[] = "Failed to assert that $not_caught triggered a deprecation notice.";
    547553        }
    548554
     
    553559
    554560        foreach ( $unexpected_deprecated as $unexpected ) {
    555             $errors[] = "Unexpected deprecation notice for $unexpected";
     561            $errors[] = "Unexpected deprecation notice for $unexpected.";
    556562            $errors[] = $this->caught_deprecated[ $unexpected ];
    557563        }
     
    563569
    564570        foreach ( $not_caught_doing_it_wrong as $not_caught ) {
    565             $errors[] = "Failed to assert that $not_caught triggered an incorrect usage notice";
     571            $errors[] = "Failed to assert that $not_caught triggered an incorrect usage notice.";
    566572        }
    567573
     
    572578
    573579        foreach ( $unexpected_doing_it_wrong as $unexpected ) {
    574             $errors[] = "Unexpected incorrect usage notice for $unexpected";
     580            $errors[] = "Unexpected incorrect usage notice for $unexpected.";
    575581            $errors[] = $this->caught_doing_it_wrong[ $unexpected ];
    576582        }
     
    601607     * @since 4.2.0
    602608     *
    603      * @param string $deprecated Name of the function, method, class, or argument that is deprecated. Must match
    604      *                           the first parameter of the `_deprecated_function()` or `_deprecated_argument()` call.
     609     * @param string $deprecated Name of the function, method, class, or argument that is deprecated.
     610     *                           Must match the first parameter of the `_deprecated_function()`
     611     *                           or `_deprecated_argument()` call.
    605612     */
    606613    public function setExpectedDeprecated( $deprecated ) {
     
    613620     * @since 4.2.0
    614621     *
    615      * @param string $doing_it_wrong Name of the function, method, or class that appears in the first argument
    616      *                               of the source `_doing_it_wrong()` call.
     622     * @param string $doing_it_wrong Name of the function, method, or class that appears in
     623     *                               the first argument of the source `_doing_it_wrong()` call.
    617624     */
    618625    public function setExpectedIncorrectUsage( $doing_it_wrong ) {
     
    625632     * This method is only left in place for backward compatibility reasons.
    626633     *
     634     * @since 4.8.0
    627635     * @deprecated 5.9.0 Use the PHPUnit native expectException*() methods directly.
    628636     *
     
    645653    /**
    646654     * Adds a deprecated function to the list of caught deprecated calls.
     655     *
     656     * @since 3.7.0
     657     * @since 6.1.0 Added the `$replacement`, `$version`, and `$message` parameters.
    647658     *
    648659     * @param string $function    The deprecated function.
     
    729740    /**
    730741     * Adds a function called in a wrong way to the list of `_doing_it_wrong()` calls.
     742     *
     743     * @since 3.7.0
     744     * @since 6.1.0 Added the `$message` and `$version` parameters.
    731745     *
    732746     * @param string $function The function to add.
Note: See TracChangeset for help on using the changeset viewer.