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. git-svn-id: https://develop.svn.wordpress.org/trunk@46221 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4ee97a4ac3
commit
5f0fb23a3b
|
@ -49,21 +49,12 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
|
||||||
/**
|
/**
|
||||||
* Retrieves the name of the class the static method is called in.
|
* Retrieves the name of the class the static method is called in.
|
||||||
*
|
*
|
||||||
|
* @deprecated 5.3.0 Use the PHP native get_called_class() function instead.
|
||||||
|
*
|
||||||
* @return string The class name.
|
* @return string The class name.
|
||||||
*/
|
*/
|
||||||
public static function get_called_class() {
|
public static function get_called_class() {
|
||||||
if ( function_exists( 'get_called_class' ) ) {
|
return get_called_class();
|
||||||
return get_called_class();
|
|
||||||
}
|
|
||||||
|
|
||||||
// PHP 5.2 only
|
|
||||||
$backtrace = debug_backtrace();
|
|
||||||
// [0] WP_UnitTestCase::get_called_class()
|
|
||||||
// [1] WP_UnitTestCase::setUpBeforeClass()
|
|
||||||
if ( 'call_user_func' === $backtrace[2]['function'] ) {
|
|
||||||
return $backtrace[2]['args'][0][0];
|
|
||||||
}
|
|
||||||
return $backtrace[2]['class'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +70,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
parent::setUpBeforeClass();
|
parent::setUpBeforeClass();
|
||||||
|
|
||||||
$c = self::get_called_class();
|
$c = get_called_class();
|
||||||
if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
|
if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
|
||||||
self::commit_transaction();
|
self::commit_transaction();
|
||||||
return;
|
return;
|
||||||
|
@ -99,7 +90,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
|
||||||
_delete_all_data();
|
_delete_all_data();
|
||||||
self::flush_cache();
|
self::flush_cache();
|
||||||
|
|
||||||
$c = self::get_called_class();
|
$c = get_called_class();
|
||||||
if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
|
if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
|
||||||
self::commit_transaction();
|
self::commit_transaction();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue