Make WordPress Core


Ignore:
Timestamp:
09/06/2022 10:03:10 PM (2 years 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/WpEmbed.php

    r51568 r54088  
    2929
    3030    public function test_maybe_run_ajax_cache_should_return_nothing_if_there_is_no_message() {
    31         $GLOBALS['post'] = $this->factory()->post->create_and_get(
     31        $GLOBALS['post'] = self::factory()->post->create_and_get(
    3232            array(
    3333                'post_title' => 'Hello World',
     
    4242
    4343    public function test_maybe_run_ajax_cache_should_return_javascript() {
    44         $GLOBALS['post'] = $this->factory()->post->create_and_get(
     44        $GLOBALS['post'] = self::factory()->post->create_and_get(
    4545            array(
    4646                'post_title' => 'Hello World',
     
    135135
    136136    public function test_delete_oembed_caches() {
    137         $post_id = $this->factory()->post->create();
     137        $post_id = self::factory()->post->create();
    138138
    139139        add_post_meta( $post_id, '_oembed_foo', 'bar' );
     
    148148
    149149    public function test_cache_oembed_invalid_post_type() {
    150         $post_id = $this->factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
     150        $post_id = self::factory()->post->create( array( 'post_type' => 'nav_menu_item' ) );
    151151
    152152        $this->wp_embed->cache_oembed( $post_id );
     
    155155
    156156    public function test_cache_oembed_empty_content() {
    157         $post_id = $this->factory()->post->create( array( 'post_content' => '' ) );
     157        $post_id = self::factory()->post->create( array( 'post_content' => '' ) );
    158158
    159159        $this->wp_embed->cache_oembed( $post_id );
     
    168168        $cachekey_time = '_oembed_time_' . $key_suffix;
    169169
    170         $post_id = $this->factory()->post->create( array( 'post_content' => 'https://example.com/' ) );
     170        $post_id = self::factory()->post->create( array( 'post_content' => 'https://example.com/' ) );
    171171
    172172        add_filter( 'pre_oembed_result', array( $this, '_pre_oembed_result_callback' ) );
     
    182182        global $post;
    183183
    184         $post       = $this->factory()->post->create_and_get();
     184        $post       = self::factory()->post->create_and_get();
    185185        $url        = 'https://example.com/';
    186186        $expected   = '<b>Embedded content</b>';
     
    209209        global $post;
    210210
    211         $post          = $this->factory()->post->create_and_get();
     211        $post          = self::factory()->post->create_and_get();
    212212        $url           = 'https://example.com/';
    213213        $expected      = '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>';
Note: See TracChangeset for help on using the changeset viewer.