mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Unit Tests: implement setUpBeforeClass() and tearDownAfterClass() on WP_UnitTestCase. Use late static binding (plus a gross fallback for PHP 5.2) to check if wpSetUpBeforeClass() or wpTearDownAfterClass() exist on the called class, and then call it and pass a static WP_UnitTest_Factory instance via Dependency Injection, if it exists.
This makes it way easier to add fixtures, and tear them down, without needing to instantiate `WP_UnitTest_Factory` in every class - removes the need to call `commit_transaction()` in each individual class. See #30017, #33968. git-svn-id: https://develop.svn.wordpress.org/trunk@35186 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7,19 +7,8 @@
|
||||
*/
|
||||
class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
static function setUpBeforeClass() {
|
||||
WP_UnitTestCase::setUpBeforeClass();
|
||||
require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->current_user = get_current_user_id();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
wp_set_current_user( $this->current_user );
|
||||
parent::tearDown();
|
||||
public static function setUpBeforeClass() {
|
||||
require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user