mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Share fixtures across a number of query-related test classes.
This shaves 10-20 seconds off the running time for the suite. See #30017. git-svn-id: https://develop.svn.wordpress.org/trunk@30276 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -10,9 +10,9 @@ class Tests_Query_Date extends WP_UnitTestCase {
|
||||
|
||||
public $q;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
static $post_ids = array();
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
// Be careful modifying this. Tests are coded to expect this exact sample data.
|
||||
$post_dates = array(
|
||||
'1972-05-24 14:53:45',
|
||||
@@ -40,10 +40,25 @@ class Tests_Query_Date extends WP_UnitTestCase {
|
||||
'2025-05-20 10:13:01',
|
||||
);
|
||||
|
||||
$factory = new WP_UnitTest_Factory;
|
||||
|
||||
foreach ( $post_dates as $post_date ) {
|
||||
$this->factory->post->create( array( 'post_date' => $post_date ) );
|
||||
self::$post_ids[] = $factory->post->create( array( 'post_date' => $post_date ) );
|
||||
}
|
||||
|
||||
self::commit_transaction();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
foreach ( self::$post_ids as $post_id ) {
|
||||
wp_delete_post( $post_id, true );
|
||||
}
|
||||
|
||||
self::commit_transaction();
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
unset( $this->q );
|
||||
$this->q = new WP_Query();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user