Make WordPress Core


Ignore:
Timestamp:
09/06/2022 10:03:10 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Tests: Correctly use the factory method.

This replaces all non-static calls to the WP_UnitTestCase_Base::factory() method with static function calls, since the method is declared as static.

This is a consistency improvement for the test suite.

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

Props jrf.
See #55652.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/controller.php

    r52010 r54088  
    291291
    292292    public function test_request_invalid_format() {
    293         $post_id = $this->factory()->post->create();
     293        $post_id = self::factory()->post->create();
    294294
    295295        $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
     
    462462
    463463    public function test_rest_pre_serve_request() {
    464         $user = $this->factory()->user->create_and_get(
     464        $user = self::factory()->user->create_and_get(
    465465            array(
    466466                'display_name' => 'John Doe',
    467467            )
    468468        );
    469         $post = $this->factory()->post->create_and_get(
     469        $post = self::factory()->post->create_and_get(
    470470            array(
    471471                'post_author' => $user->ID,
     
    486486
    487487    public function test_rest_pre_serve_request_wrong_format() {
    488         $post = $this->factory()->post->create_and_get();
     488        $post = self::factory()->post->create_and_get();
    489489
    490490        $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
     
    498498
    499499    public function test_rest_pre_serve_request_wrong_method() {
    500         $post = $this->factory()->post->create_and_get();
     500        $post = self::factory()->post->create_and_get();
    501501
    502502        $request = new WP_REST_Request( 'HEAD', '/oembed/1.0/embed' );
     
    514514        $this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
    515515
    516         $post_id     = $this->factory()->post->create();
     516        $post_id     = self::factory()->post->create();
    517517        $url         = get_permalink( $post_id );
    518518        $url_encoded = urlencode( $url );
     
    528528        $this->assertSame( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
    529529
    530         $post_id     = $this->factory()->post->create();
     530        $post_id     = self::factory()->post->create();
    531531        $url         = get_permalink( $post_id );
    532532        $url_encoded = urlencode( $url );
Note: See TracChangeset for help on using the changeset viewer.