Make WordPress Core


Ignore:
Timestamp:
01/30/2015 04:47:44 PM (10 years ago)
Author:
boonebgorges
Message:

Introduce setExpectedDeprecated() and setExpectedIncorrectUsage() methods to `WP_UnitTestCase.

These methods provide a procedural alternative to the @expectedDeprecated
and @expectedIncorrectUsage test annotations, and parallel PHPUnit's native
setExpectedException().

Props prasoon2211, jdgrimes.
Fixes #28486.

File:
1 edited

Legend:

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

    r31046 r31306  
    244244            $this->fail( "Unexpected incorrect usage notice for $unexpected" );
    245245        }
     246    }
     247
     248    /**
     249     * Declare an expected `_deprecated_function()` or `_deprecated_argument()` call from within a test.
     250     *
     251     * @since 4.2.0
     252     *
     253     * @param string $deprecated Name of the function, method, class, or argument that is deprecated. Must match
     254     *                           first parameter of the `_deprecated_function()` or `_deprecated_argument()` call.
     255     */
     256    public function setExpectedDeprecated( $deprecated ) {
     257        array_push( $this->expected_deprecated, $deprecated );
     258    }
     259
     260    /**
     261     * Declare an expected `_doing_it_wrong()` call from within a test.
     262     *
     263     * @since 4.2.0
     264     *
     265     * @param string $deprecated Name of the function, method, or class that appears in the first argument of the
     266     *                           source `_doing_it_wrong()` call.
     267     */
     268    public function setExpectedIncorrectUsage( $doing_it_wrong ) {
     269        array_push( $this->expected_doing_it_wrong, $doing_it_wrong );
    246270    }
    247271
Note: See TracChangeset for help on using the changeset viewer.