Make WordPress Core

Changeset 1060 in tests for trunk/tests/ms.php


Ignore:
Timestamp:
10/01/2012 06:03:48 PM (13 years ago)
Author:
ryan
Message:

Test for get_blog_id_from_url(). see #WP18387

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r1055 r1060  
    2727            $this->assertEquals( $blog_id, get_id_from_blogname( $details->path ) );
    2828            $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
     29
     30            // get_blog_id_from_url()
     31            $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
     32            $key = md5( $details->domain . $details->path );
     33            $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
    2934
    3035            // These are empty until get_blog_details() is called with $get_all = true
     
    6974            $key = md5( $details->domain . $details->path );
    7075            $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
     76            $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
    7177
    7278            $prefix = $wpdb->get_blog_prefix( $blog_id );
     
    531537        $this->assertEquals( null, domain_exists( $details->domain, $details->path ) );
    532538    }
     539
     540    function test_get_blog_id_from_url() {
     541        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     542        $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/testdomainexists', 'title' => 'Test Title' ) );
     543   
     544        $details = get_blog_details( $blog_id, false );
     545
     546        $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
     547        $key = md5( $details->domain . $details->path );
     548        $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );
     549
     550        $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
     551
     552        wpmu_delete_blog( $blog_id );
     553        $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
     554        wpmu_delete_blog( $blog_id, true );
     555
     556        $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );
     557        $this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) );
     558    }
    533559}
    534560
Note: See TracChangeset for help on using the changeset viewer.