WordPress.org

Make WordPress Core

Changeset 1247 in tests


Ignore:
Timestamp:
03/19/13 05:00:25 (13 months ago)
Author:
ryan
Message:

Test get_blog_details() and the blog-details cache before, while, and after a blog exists.

see #WP23405

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r1216 r1247  
    524524    } 
    525525 
     526    /** 
     527     * Test fetching a blog that doesn't exist and again after it exists. 
     528     *  
     529     * 23405 
     530     */ 
     531    function test_get_blog_details_blog_does_not_exist() { 
     532        global $wpdb; 
     533 
     534        $blog_id = $wpdb->get_var( "SELECT MAX(blog_id) FROM $wpdb->blogs" ); 
     535 
     536        // An idosyncrancy of the unit tests is that the max blog_id gets reset 
     537        // to 1 in between test cases but picks up where it previously left off 
     538        // on the next insert. If 1 is reported, burn a blog create to get 
     539        // the max counter back in sync. 
     540        if ( 1 == $blog_id ) { 
     541            $blog_id = $this->factory->blog->create(); 
     542        } 
     543        $blog_id++; 
     544 
     545        $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); 
     546        $this->assertFalse( get_blog_details( $blog_id ) ); 
     547        $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); 
     548        $this->assertFalse( get_blog_details( $blog_id ) ); 
     549        $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); 
     550 
     551        $this->assertEquals( $blog_id, $this->factory->blog->create() ); 
     552        $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' )  ); 
     553 
     554        $blog = get_blog_details( $blog_id ); 
     555        $this->assertEquals( $blog_id, $blog->blog_id ); 
     556        $this->assertEquals( $blog, wp_cache_get( $blog_id, 'blog-details' ) ); 
     557 
     558        wpmu_delete_blog( $blog_id ); 
     559        $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); 
     560        $blog->deleted = '1'; 
     561        $this->assertEQuals( $blog, get_blog_details( $blog_id ) ); 
     562        $this->assertEquals( $blog, wp_cache_get( $blog_id, 'blog-details' ) ); 
     563 
     564        wpmu_delete_blog( $blog_id, true ); 
     565        $this->assertFalse( get_blog_details( $blog_id ) ); 
     566        $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); 
     567    } 
     568 
    526569    function test_update_blog_status() { 
    527570        global $test_action_counter; 
Note: See TracChangeset for help on using the changeset viewer.