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/oembed/template.php

    r35235 r35242  
    66class Tests_Embed_Template extends WP_UnitTestCase {
    77        function test_oembed_output_post() {
    8                 $user = self::$factory->user->create_and_get( array(
     8                $user = self::factory()->user->create_and_get( array(
    99                        'display_name' => 'John Doe',
    1010                ) );
    1111
    12                 $post_id = self::$factory->post->create( array(
     12                $post_id = self::factory()->post->create( array(
    1313                        'post_author'  => $user->ID,
    1414                        'post_title'   => 'Hello World',
     
    3131
    3232        function test_oembed_output_post_with_thumbnail() {
    33                 $post_id       = self::$factory->post->create( array(
     33                $post_id       = self::factory()->post->create( array(
    3434                        'post_title'   => 'Hello World',
    3535                        'post_content' => 'Foo Bar',
     
    3737                ) );
    3838                $file          = DIR_TESTDATA . '/images/canola.jpg';
    39                 $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
     39                $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array(
    4040                        'post_mime_type' => 'image/jpeg',
    4141                ) );
     
    7373
    7474        function test_oembed_output_attachment() {
    75                 $post          = self::$factory->post->create_and_get();
     75                $post          = self::factory()->post->create_and_get();
    7676                $file          = DIR_TESTDATA . '/images/canola.jpg';
    77                 $attachment_id = self::$factory->attachment->create_object( $file, $post->ID, array(
     77                $attachment_id = self::factory()->attachment->create_object( $file, $post->ID, array(
    7878                        'post_mime_type' => 'image/jpeg',
    7979                        'post_title'     => 'Hello World',
     
    9898
    9999        function test_oembed_output_draft_post() {
    100                 $post_id = self::$factory->post->create( array(
     100                $post_id = self::factory()->post->create( array(
    101101                        'post_title'   => 'Hello World',
    102102                        'post_content' => 'Foo Bar',
     
    119119
    120120        function test_oembed_output_scheduled_post() {
    121                 $post_id = self::$factory->post->create( array(
     121                $post_id = self::factory()->post->create( array(
    122122                        'post_title'   => 'Hello World',
    123123                        'post_content' => 'Foo Bar',
     
    141141
    142142        function test_oembed_output_private_post() {
    143                 $post_id = self::$factory->post->create( array(
     143                $post_id = self::factory()->post->create( array(
    144144                        'post_title'   => 'Hello World',
    145145                        'post_content' => 'Foo Bar',
     
    162162
    163163        function test_oembed_output_private_post_with_permissions() {
    164                 $user_id = self::$factory->user->create( array( 'role' => 'editor' ) );
     164                $user_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    165165                wp_set_current_user( $user_id );
    166166
    167                 $post_id = self::$factory->post->create( array(
     167                $post_id = self::factory()->post->create( array(
    168168                        'post_title'   => 'Hello World',
    169169                        'post_content' => 'Foo Bar',
     
    194194
    195195        function test_wp_embed_excerpt_more() {
    196                 $post_id = self::$factory->post->create( array(
     196                $post_id = self::factory()->post->create( array(
    197197                        'post_content' => 'Foo Bar',
    198198                ) );
     
    215215                $this->assertFalse( is_embed() );
    216216
    217                 $post_id = self::$factory->post->create();
     217                $post_id = self::factory()->post->create();
    218218                $this->go_to( get_post_embed_url( $post_id ) );
    219219                $this->assertTrue( is_embed() );
     
    221221
    222222        function test_is_embed_attachment() {
    223                 $post_id       = self::$factory->post->create();
     223                $post_id       = self::factory()->post->create();
    224224                $file          = DIR_TESTDATA . '/images/canola.jpg';
    225                 $attachment_id = self::$factory->attachment->create_object( $file, $post_id, array(
     225                $attachment_id = self::factory()->attachment->create_object( $file, $post_id, array(
    226226                        'post_mime_type' => 'image/jpeg',
    227227                ) );
     
    241241
    242242        function test_get_post_embed_html() {
    243                 $post_id = self::$factory->post->create();
     243                $post_id = self::factory()->post->create();
    244244
    245245                $expected = '<iframe sandbox="allow-scripts" security="restricted" src="' . esc_url( get_post_embed_url( $post_id ) ) . '" width="200" height="200" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>';
Note: See TracChangeset for help on using the changeset viewer.