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
This commit is contained in:
Sergey Biryukov 2020-09-19 09:11:23 +00:00
parent 1ffdfdaea7
commit 1ec9dc6fa4

View File

@ -70,13 +70,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
parent::setUpBeforeClass(); parent::setUpBeforeClass();
$c = get_called_class(); $class = get_called_class();
if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
self::commit_transaction();
return;
}
call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() ); if ( method_exists( $class, 'wpSetUpBeforeClass' ) ) {
call_user_func( array( $class, 'wpSetUpBeforeClass' ), self::factory() );
}
self::commit_transaction(); self::commit_transaction();
} }
@ -90,13 +88,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
_delete_all_data(); _delete_all_data();
self::flush_cache(); self::flush_cache();
$c = get_called_class(); $class = get_called_class();
if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
self::commit_transaction();
return;
}
call_user_func( array( $c, 'wpTearDownAfterClass' ) ); if ( method_exists( $class, 'wpTearDownAfterClass' ) ) {
call_user_func( array( $class, 'wpTearDownAfterClass' ) );
}
self::commit_transaction(); self::commit_transaction();
} }