Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (9 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php

    r35225 r35242  
    127127        // create attachment
    128128        $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
    129         $attachment_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
     129        $attachment_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    130130
    131131        // add post thumbnail to post that does not have one
     
    149149
    150150        // create another attachment
    151         $attachment2_id = self::$factory->attachment->create_upload_object( $filename, $post_id );
     151        $attachment2_id = self::factory()->attachment->create_upload_object( $filename, $post_id );
    152152
    153153        // change the post's post_thumbnail
     
    209209        $editor_id = $this->make_user_by_role( 'editor' );
    210210
    211         $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
     211        $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) );
    212212        stick_post( $post_id );
    213213
     
    221221        // when transitioning to private status or adding a post password, post should be un-stuck
    222222        $editor_id = $this->make_user_by_role( 'editor' );
    223         $post_id = self::$factory->post->create( array( 'post_author' => $editor_id ) );
     223        $post_id = self::factory()->post->create( array( 'post_author' => $editor_id ) );
    224224        stick_post( $post_id );
    225225
     
    235235        $yesterday = strtotime( '-1 day' );
    236236
    237         $post_id = self::$factory->post->create( array(
     237        $post_id = self::factory()->post->create( array(
    238238            'post_title'   => 'Post Revision Test',
    239239            'post_content' => 'Not edited',
     
    264264        $editor_id = $this->make_user_by_role( 'editor' );
    265265
    266         $post_id = self::$factory->post->create( array(
     266        $post_id = self::factory()->post->create( array(
    267267            'post_title'   => 'Post Revision Test',
    268268            'post_content' => 'Not edited',
     
    283283        $editor_id = $this->make_user_by_role( 'editor' );
    284284
    285         $post_id = self::$factory->post->create( array(
     285        $post_id = self::factory()->post->create( array(
    286286            'post_title'   => 'Post Revision Test',
    287287            'post_content' => 'Not edited',
     
    303303        $editor_id = $this->make_user_by_role( 'editor' );
    304304
    305         $post_id = self::$factory->post->create( array( 'post_author'  => $editor_id ) );
    306         $term_id = self::$factory->category->create();
    307         self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true );
     305        $post_id = self::factory()->post->create( array( 'post_author'  => $editor_id ) );
     306        $term_id = self::factory()->category->create();
     307        self::factory()->term->add_post_terms( $post_id, $term_id, 'category', true );
    308308        $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
    309309        $this->assertContains( $term_id, $term_ids );
     
    323323        $editor_id = $this->make_user_by_role( 'editor' );
    324324
    325         $post_id = self::$factory->post->create( array( 'post_author'  => $editor_id ) );
    326         $term_id = self::$factory->category->create();
    327         self::$factory->term->add_post_terms( $post_id, $term_id, 'category', true );
     325        $post_id = self::factory()->post->create( array( 'post_author'  => $editor_id ) );
     326        $term_id = self::factory()->category->create();
     327        self::factory()->term->add_post_terms( $post_id, $term_id, 'category', true );
    328328        $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
    329329        $this->assertContains( $term_id, $term_ids );
     
    366366
    367367        // Add a dummy post
    368         $post_id = self::$factory->post->create( array(
     368        $post_id = self::factory()->post->create( array(
    369369            'post_title'   => 'Post Enclosure Test',
    370370            'post_content' => 'Fake content',
Note: See TracChangeset for help on using the changeset viewer.