Make WordPress Core

Changeset 1055 in tests


Ignore:
Timestamp:
09/27/2012 05:30:59 PM (12 years ago)
Author:
ryan
Message:

Tests for domain_exists(). see #WP21142

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r1046 r1055  
    499499        }
    500500    }
     501
     502    function test_domain_exists() {
     503        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     504        $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/testdomainexists', 'title' => 'Test Title' ) );
     505   
     506        $details = get_blog_details( $blog_id, false );
     507       
     508        $this->assertEquals( $blog_id, domain_exists( $details->domain, $details->path ) );
     509        $this->assertEquals( $blog_id, domain_exists( $details->domain, $details->path, $details->site_id ) );
     510        $this->assertEquals( null, domain_exists( $details->domain, $details->path, 999 ) );
     511        $this->assertEquals( null, domain_exists( 'foo', 'bar' ) );
     512
     513        $exists_cb = function ( $exists, $domain, $path, $site_id ) {
     514            if ( 'foo' == $domain && 'bar' == $path )
     515                return 1234;
     516            else
     517                return null;
     518        };
     519
     520        add_filter( 'domain_exists', $exists_cb, 10, 4 );
     521        $this->assertEquals( 1234, domain_exists( 'foo', 'bar' ) );
     522        $this->assertEquals( null, domain_exists( 'foo', 'baz' ) );
     523        $this->assertEquals( null, domain_exists( 'bar', 'foo' ) );
     524
     525        remove_filter( 'domain_exists', $exists_cb, 10, 4 );
     526        $this->assertEquals( null, domain_exists( 'foo', 'bar' ) );
     527
     528        wpmu_delete_blog( $blog_id );
     529        $this->assertEquals( $blog_id, domain_exists( $details->domain, $details->path ) );
     530        wpmu_delete_blog( $blog_id, true );
     531        $this->assertEquals( null, domain_exists( $details->domain, $details->path ) );
     532    }
    501533}
    502534
Note: See TracChangeset for help on using the changeset viewer.