Make WordPress Core

Changeset 35163


Ignore:
Timestamp:
10/14/2015 09:29:59 PM (11 years ago)
Author:
boonebgorges
Message:

Share fixtures in Tests_Get_Archives.

See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions/getArchives.php

    r34686 r35163  
    99*/
    1010class Tests_Get_Archives extends WP_UnitTestCase {
    11         protected $post_ids;
     11        protected static $post_ids;
    1212        protected $month_url;
    1313
     
    1717                $this->month_url = get_month_link( date( 'Y' ), date( 'm' ) );
    1818                $this->year_url = get_year_link( date( 'Y' ) );
    19                 $this->post_ids = $this->factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
     19        }
     20
     21        public static function setUpBeforeClass() {
     22                $factory = new WP_UnitTest_Factory();
     23                self::$post_ids = $factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
     24
     25                self::commit_transaction();
     26        }
     27
     28        public static function tearDownAfterClass() {
     29                foreach ( self::$post_ids as $post_id ) {
     30                        wp_delete_post( $post_id, true );
     31                }
     32
     33                self::commit_transaction();
    2034        }
    2135
     
    3145
    3246        function test_wp_get_archives_limit() {
    33                 $ids = array_slice( array_reverse( $this->post_ids ), 0, 5 );
     47                $ids = array_slice( array_reverse( self::$post_ids ), 0, 5 );
    3448
    3549                $link1 = get_permalink( $ids[0] );
Note: See TracChangeset for help on using the changeset viewer.