Make WordPress Core

Changeset 39172


Ignore:
Timestamp:
11/08/2016 11:31:45 PM (10 years ago)
Author:
johnbillion
Message:

Themes: Re-use fixtures in the wp_get_document_title() tests.

See #38716

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/document-title.php

    r38762 r39172  
    1010
    1111        public $blog_name;
    12 
    13         function setUp() {
    14                 parent::setUp();
    15 
    16                 add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );
    17 
    18                 $this->category_id = $this->factory->category->create( array(
     12        public static $category_id;
     13        public static $author_id;
     14        public static $post_id;
     15
     16        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     17                self::$category_id = $factory->category->create( array(
    1918                        'name' => 'test_category',
    2019                ) );
    2120
    22                 $this->author_id = $this->factory->user->create( array(
     21                self::$author_id = $factory->user->create( array(
    2322                        'role'        => 'author',
    2423                        'user_login'  => 'test_author',
    … …  
    2625                ) );
    2726
    28                 $this->post_id = $this->factory->post->create( array(
    29                         'post_author'  => $this->author_id,
     27                self::$post_id = $factory->post->create( array(
     28                        'post_author'  => self::$author_id,
    3029                        'post_status'  => 'publish',
    3130                        'post_title'   => 'test_title',
    3231                        'post_type'    => 'post',
    3332                        'post_date'    => '2015-09-22 18:52:17',
    34                         'category'     => $this->category_id,
    35                 ) );
     33                        'category'     => self::$category_id,
     34                ) );
     35        }
     36
     37        function setUp() {
     38                parent::setUp();
     39
     40                add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );
    3641
    3742                $this->blog_name = get_option( 'blogname' );
    3843
    39                 setup_postdata( get_post( $this->post_id ) );
     44                setup_postdata( get_post( self::$post_id ) );
    4045        }
    4146
    … …  
    127132
    128133        function test_singular_title() {
    129                 $this->go_to( '?p=' . $this->post_id );
     134                $this->go_to( '?p=' . self::$post_id );
    130135
    131136                add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) );
    … …  
    143148
    144149        function test_category_title() {
    145                 $this->go_to( '?cat=' . $this->category_id );
     150                $this->go_to( '?cat=' . self::$category_id );
    146151
    147152                $this->assertEquals( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() );
    … …  
    155160
    156161        function test_author_title() {
    157                 $this->go_to( '?author=' . $this->author_id );
     162                $this->go_to( '?author=' . self::$author_id );
    158163
    159164                $this->assertEquals( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() );
    … …  
    203208
    204209        function test_paged_post_title() {
    205                 $this->go_to( '?paged=4&p=' . $this->post_id );
     210                $this->go_to( '?paged=4&p=' . self::$post_id );
    206211
    207212                add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) );
    … …  
    220225
    221226        function test_rearrange_title_parts() {
    222                 $this->go_to( '?p=' . $this->post_id );
     227                $this->go_to( '?p=' . self::$post_id );
    223228
    224229                add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) );
    … …  
    237242
    238243        function test_change_title_separator() {
    239                 $this->go_to( '?p=' . $this->post_id );
     244                $this->go_to( '?p=' . self::$post_id );
    240245
    241246                add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) );
Note: See TracChangeset for help on using the changeset viewer.