Make WordPress Core

Changeset 990 in tests


Ignore:
Timestamp:
08/24/2012 06:51:56 PM (12 years ago)
Author:
ryan
Message:

get_blog_post() tests. see #WP21595

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r989 r990  
    362362        $this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) );
    363363
    364         $domain = 'blogoptiontest';
    365         if ( is_subdomain_install() ) {
    366             $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
    367             $path = $base;
    368         } else {
    369             $newdomain = $current_site->domain;
    370             $path = $base . $domain . '/';
    371         }
    372         $email = 'foo@foo.foo';
    373         $password = wp_generate_password( 12, false );
    374         $user_id = wpmu_create_user( $domain, $password, $email );
    375         $this->assertInternalType( 'integer', $user_id );
    376         $blog_id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
    377         $this->assertInternalType( 'integer', $blog_id );
     364        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     365        $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );
    378366
    379367        switch_to_blog( $blog_id );
     
    405393        $this->assertFalse( restore_current_blog() );
    406394    }
     395
     396    function test_get_blog_post() {
     397        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     398        $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );
     399        $current_blog_id = get_current_blog_id();
     400
     401        $post_id = $this->factory->post->create();
     402        //$this->assertInstanceOf( 'WP_Post', get_post( $post_id ) );
     403        switch_to_blog( $blog_id );
     404        $this->assertNull( get_post( $post_id ) );
     405        $post = get_blog_post( $current_blog_id, $post_id );
     406        //$this->assertInstanceOf( 'WP_Post', $post );
     407        $this->assertEquals( $post_id, $post->ID );
     408        restore_current_blog();
     409
     410        wp_update_post( array( 'ID' => $post_id, 'post_title' => 'A Different Title' ) );
     411        switch_to_blog( $blog_id );
     412        $post = get_blog_post( $current_blog_id, $post_id );
     413        // Make sure cache is good
     414        $this->assertEquals( 'A Different Title', $post->post_title );
     415
     416        $post_id2 = $this->factory->post->create();
     417        // Test get_blog_post() with currently active blog ID.
     418        $post = get_blog_post( $blog_id, $post_id2 );
     419        //$this->assertInstanceOf( 'WP_Post', $post );
     420        $this->assertEquals( $post_id2, $post->ID );
     421    }
    407422}
    408423
Note: See TracChangeset for help on using the changeset viewer.