From 1ec9dc6fa46b23f7724dfa3f057e2da1a1dd3133 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 19 Sep 2020 09:11:23 +0000 Subject: [PATCH] Tests: Simplify the logic in `WP_UnitTestCase_Base::setUpBeforeClass()` and `::tearDownAfterClass()`. See #51344. git-svn-id: https://develop.svn.wordpress.org/trunk@49001 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/abstract-testcase.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index 94c7aaf634..79276c0174 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -70,13 +70,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase { parent::setUpBeforeClass(); - $c = get_called_class(); - if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { - self::commit_transaction(); - return; - } + $class = get_called_class(); - call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() ); + if ( method_exists( $class, 'wpSetUpBeforeClass' ) ) { + call_user_func( array( $class, 'wpSetUpBeforeClass' ), self::factory() ); + } self::commit_transaction(); } @@ -90,13 +88,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase { _delete_all_data(); self::flush_cache(); - $c = get_called_class(); - if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { - self::commit_transaction(); - return; - } + $class = get_called_class(); - call_user_func( array( $c, 'wpTearDownAfterClass' ) ); + if ( method_exists( $class, 'wpTearDownAfterClass' ) ) { + call_user_func( array( $class, 'wpTearDownAfterClass' ) ); + } self::commit_transaction(); }