From 5e528bd801a432506f916f0fd4e469734ded21fe Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sat, 27 Jul 2019 04:33:43 +0200
Subject: [PATCH] [tests] Remove work-arounds for get_called_class()
---
tests/phpunit/includes/abstract-testcase.php | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php
index f1c08657cb..b31b7a2c90 100644
a
|
b
|
abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase { |
49 | 49 | /** |
50 | 50 | * Retrieves the name of the class the static method is called in. |
51 | 51 | * |
| 52 | * @deprecated 5.3.0 Use the PHP native get_called_class() function instead. |
| 53 | * |
52 | 54 | * @return string The class name. |
53 | 55 | */ |
54 | 56 | 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(); |
67 | 58 | } |
68 | 59 | |
69 | 60 | /** |
… |
… |
abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase { |
79 | 70 | |
80 | 71 | parent::setUpBeforeClass(); |
81 | 72 | |
82 | | $c = self::get_called_class(); |
| 73 | $c = get_called_class(); |
83 | 74 | if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { |
84 | 75 | self::commit_transaction(); |
85 | 76 | return; |
… |
… |
abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase { |
99 | 90 | _delete_all_data(); |
100 | 91 | self::flush_cache(); |
101 | 92 | |
102 | | $c = self::get_called_class(); |
| 93 | $c = get_called_class(); |
103 | 94 | if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { |
104 | 95 | self::commit_transaction(); |
105 | 96 | return; |