Share fixtures in `Tests_Get_Archives`.

See #30017, #33968.

git-svn-id: https://develop.svn.wordpress.org/trunk@35163 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-10-14 21:29:59 +00:00
parent 6c28fe3853
commit 9f7bfa9805
1 changed files with 17 additions and 3 deletions

View File

@ -8,7 +8,7 @@ $defaults = array(
);
*/
class Tests_Get_Archives extends WP_UnitTestCase {
protected $post_ids;
protected static $post_ids;
protected $month_url;
function setUp() {
@ -16,7 +16,21 @@ class Tests_Get_Archives extends WP_UnitTestCase {
$this->month_url = get_month_link( date( 'Y' ), date( 'm' ) );
$this->year_url = get_year_link( date( 'Y' ) );
$this->post_ids = $this->factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
}
public static function setUpBeforeClass() {
$factory = new WP_UnitTest_Factory();
self::$post_ids = $factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
self::commit_transaction();
}
public static function tearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
self::commit_transaction();
}
function test_wp_get_archives_default() {
@ -30,7 +44,7 @@ class Tests_Get_Archives extends WP_UnitTestCase {
}
function test_wp_get_archives_limit() {
$ids = array_slice( array_reverse( $this->post_ids ), 0, 5 );
$ids = array_slice( array_reverse( self::$post_ids ), 0, 5 );
$link1 = get_permalink( $ids[0] );
$link2 = get_permalink( $ids[1] );