Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (11 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/post/formats.php

    r35225 r35242  
    1010
    1111        function test_set_get_post_format_for_post() {
    12                 $post_id = self::$factory->post->create();
     12                $post_id = self::factory()->post->create();
    1313
    1414                $format = get_post_format( $post_id );
     
    3838         */
    3939        function test_set_get_post_format_for_page() {
    40                 $post_id = self::$factory->post->create( array( 'post_type' => 'page' ) );
     40                $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
    4141
    4242                $format = get_post_format( $post_id );
     
    7070
    7171        function test_has_format() {
    72                 $post_id = self::$factory->post->create();
     72                $post_id = self::factory()->post->create();
    7373
    7474                $this->assertFalse( has_post_format( 'standard', $post_id ) );
     
    112112$commentary
    113113DATA;
    114                 $link_post_id = self::$factory->post->create( array( 'post_content' => $link ) );
     114                $link_post_id = self::factory()->post->create( array( 'post_content' => $link ) );
    115115                $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) );
    116116                $this->assertEquals( false, $content_link );
    117117
    118                 $link_with_post_id = self::$factory->post->create( array( 'post_content' => $link_with_commentary ) );
     118                $link_with_post_id = self::factory()->post->create( array( 'post_content' => $link_with_commentary ) );
    119119                $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) );
    120120                $this->assertEquals( false, $content_link );
     
    126126                $this->assertEquals( false, $content_link );
    127127
    128                 $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) );
     128                $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) );
    129129                $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
    130130                $this->assertEquals( false, $content_link );
    131131
    132                 $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) );
     132                $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) );
    133133                $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
    134134                $this->assertEquals( false, $content_link );
    135135
    136136                // Now with an href
    137                 $href_post_id = self::$factory->post->create( array( 'post_content' => $href ) );
     137                $href_post_id = self::factory()->post->create( array( 'post_content' => $href ) );
    138138                $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) );
    139139                $this->assertEquals( $link, $content_link );
    140140
    141                 $href_with_post_id = self::$factory->post->create( array( 'post_content' => $href_with_commentary ) );
     141                $href_with_post_id = self::factory()->post->create( array( 'post_content' => $href_with_commentary ) );
    142142                $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) );
    143143                $this->assertEquals( $link, $content_link );
     
    149149                $this->assertEquals( $link, $content_link );
    150150
    151                 $empty_post_id = self::$factory->post->create( array( 'post_content' => '' ) );
     151                $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) );
    152152                $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) );
    153153                $this->assertEquals( false, $content_link );
    154154
    155                 $comm_post_id = self::$factory->post->create( array( 'post_content' => $commentary ) );
     155                $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) );
    156156                $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) );
    157157                $this->assertEquals( false, $content_link );
Note: See TracChangeset for help on using the changeset viewer.