Make WordPress Core


Ignore:
Timestamp:
09/06/2022 10:09:49 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use the factory method instead of the property.

This replaces all references to the WP_UnitTestCase_Base::$factory property with static function calls to the WP_UnitTestCase_Base::factory() method.

This is a consistency improvement for the test suite.

Follow up to [35225], [35242], [49603], [54087], [54088].

Props jrf.
See #55652.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/wpPublishPost.php

    r53783 r54090  
    143143    public function test_wp_publish_post_respects_current_categories() {
    144144        $post_id     = self::$auto_draft_id;
    145         $category_id = $this->factory->term->create( array( 'taxonomy' => 'category' ) );
     145        $category_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
    146146        wp_set_post_categories( $post_id, $category_id );
    147147        wp_publish_post( $post_id );
     
    184184    public function test_wp_publish_post_adds_default_category_when_tagged() {
    185185        $post_id = self::$auto_draft_id;
    186         $tag_id  = $this->factory->term->create( array( 'taxonomy' => 'post_tag' ) );
     186        $tag_id  = self::factory()->term->create( array( 'taxonomy' => 'post_tag' ) );
    187187        wp_set_post_tags( $post_id, array( $tag_id ) );
    188188        wp_publish_post( $post_id );
     
    219219
    220220        $post_id = self::$auto_draft_id;
    221         $term_id = $this->factory->term->create( array( 'taxonomy' => 'tax_51292' ) );
     221        $term_id = self::factory()->term->create( array( 'taxonomy' => 'tax_51292' ) );
    222222        wp_set_object_terms( $post_id, array( $term_id ), 'tax_51292' );
    223223        wp_publish_post( $post_id );
Note: See TracChangeset for help on using the changeset viewer.