Make WordPress Core

Changeset 46221


Ignore:
Timestamp:
09/20/2019 10:39:23 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Tests: Remove a workaround for get_called_class().

The get_called_class() function was introduced in PHP 5.3, so no longer needs a workaround.

Mark WP_UnitTestCase_Base::get_called_class() as deprecated. Leave it in place for now as plugins or themes using the WP unit test framework might still call this method.

Props jrf.
See #48074.

File:
1 edited

Legend:

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

    r46127 r46221  
    5050     * Retrieves the name of the class the static method is called in.
    5151     *
     52     * @deprecated 5.3.0 Use the PHP native get_called_class() function instead.
     53     *
    5254     * @return string The class name.
    5355     */
    5456    public static function get_called_class() {
    55         if ( function_exists( 'get_called_class' ) ) {
    56             return get_called_class();
    57         }
    58 
    59         // PHP 5.2 only
    60         $backtrace = debug_backtrace();
    61         // [0] WP_UnitTestCase::get_called_class()
    62         // [1] WP_UnitTestCase::setUpBeforeClass()
    63         if ( 'call_user_func' === $backtrace[2]['function'] ) {
    64             return $backtrace[2]['args'][0][0];
    65         }
    66         return $backtrace[2]['class'];
     57        return get_called_class();
    6758    }
    6859
     
    8071        parent::setUpBeforeClass();
    8172
    82         $c = self::get_called_class();
     73        $c = get_called_class();
    8374        if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
    8475            self::commit_transaction();
     
    10091        self::flush_cache();
    10192
    102         $c = self::get_called_class();
     93        $c = get_called_class();
    10394        if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
    10495            self::commit_transaction();
Note: See TracChangeset for help on using the changeset viewer.