Make WordPress Core

Ticket #24173: 24173.02.patch

File 24173.02.patch, 7.5 KB (added by r-a-y, 12 years ago)
  • includes/bootstrap.php

    if ( $multisite ) { 
    4848        define( 'MULTISITE', true );
    4949        define( 'SUBDOMAIN_INSTALL', false );
    5050        define( 'DOMAIN_CURRENT_SITE', WP_TESTS_DOMAIN );
    51         define( 'PATH_CURRENT_SITE', '/' );
     51
     52        if ( defined( 'PATH_CURRENT_SITE' ) ) {
     53                $_SERVER['REQUEST_URI'] = PATH_CURRENT_SITE;
     54        } else {
     55                define( 'PATH_CURRENT_SITE', '/' );
     56        }
     57
    5258        define( 'SITE_ID_CURRENT_SITE', 1 );
    5359        define( 'BLOG_ID_CURRENT_SITE', 1 );
    54         $GLOBALS['base'] = '/';
     60        $GLOBALS['base'] = PATH_CURRENT_SITE;
    5561} else {
    5662        echo "Running as single site... To run multisite, use -c multisite.xml" . PHP_EOL;
    5763}
  • includes/install.php

    foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { 
    5050                $wpdb->$table = $prefixed_table;
    5151}
    5252
     53if ( $multisite ) {
     54        if ( defined( 'PATH_CURRENT_SITE' ) ) {
     55                $path = PATH_CURRENT_SITE;
     56        } else {
     57                $path = '/';
     58        }
     59
     60        // This will override wp_guess_url() when populating the install
     61        // Note: we're suffixing with 'wordpress' since our WP install is in a subdirectory
     62        define( 'WP_SITEURL', 'http://' . WP_TESTS_DOMAIN . $path . 'wordpress' );
     63}
     64
    5365wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' );
    5466
    5567if ( $multisite ) {
    if ( $multisite ) { 
    6173        $subdomain_install = false;
    6274
    6375        install_network();
    64         populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install );
     76        populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, $path, $subdomain_install );
    6577}
    6678
    6779file_put_contents( WP_TESTS_VERSION_FILE, $hash );
  • tests/ms.php

    class Tests_MS extends WP_UnitTestCase { 
    2323                        $details = get_blog_details( $blog_id, false );
    2424                        $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
    2525
     26                        // support subdirectory installs
     27                        if ( defined( 'PATH_CURRENT_SITE' ) ) {
     28                                $slug = str_replace( PATH_CURRENT_SITE, '/', $details->path );
     29                        } else {
     30                                $slug = $details->path;
     31                        }
     32                        $slug = trim( $slug, '/' );
     33
    2634                        // get_id_from_blogname(), see #20950
    27                         $this->assertEquals( $blog_id, get_id_from_blogname( $details->path ) );
    28                         $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
     35                        $this->assertEquals( $blog_id, get_id_from_blogname( $slug ) );
     36                        $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ) );
    2937
    3038                        // get_blog_id_from_url()
    3139                        $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
    class Tests_MS extends WP_UnitTestCase { 
    352360                $blog = get_blog_details( $blog_id );
    353361                $this->assertEquals( $blog_id, $blog->blog_id );
    354362                $this->assertEquals( $current_site->domain, $blog->domain );
    355                 $this->assertEquals( '/', $blog->path );
     363                $this->assertEquals( PATH_CURRENT_SITE, $blog->path );
    356364
    357365                // Test defaulting to current blog
    358366                $this->assertEquals( $blog, get_blog_details() );
    359 
    360367                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    361                 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogname', 'title' => 'Test Title' ) );
     368                $blog_id = $this->factory->blog->create( array(
     369                        'user_id' => $user_id,
     370                        'path'    => PATH_CURRENT_SITE . 'test_blogname',
     371                        'title'   => 'Test Title'
     372                ) );
    362373                $this->assertInternalType( 'int', $blog_id );
    363 
    364374                $this->assertEquals( 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . 'test_blogname/', get_blogaddress_by_name('test_blogname') );
    365375
    366                 $this->assertEquals( $blog_id, get_id_from_blogname('test_blogname') );
     376                $this->assertEquals( $blog_id, get_id_from_blogname( 'test_blogname' ) );
    367377        }
    368378
    369379        function _action_counter_cb( $blog_id ) {
    class Tests_MS extends WP_UnitTestCase { 
    525535
    526536        /**
    527537         * Test fetching a blog that doesn't exist and again after it exists.
    528          * 
     538         *
    529539         * @ticket 23405
    530540         */
    531541        function test_get_blog_details_blog_does_not_exist() {
    class Tests_MS extends WP_UnitTestCase { 
    570580                global $test_action_counter;
    571581
    572582                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    573                 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );
     583                $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => PATH_CURRENT_SITE . 'test_blogpath', 'title' => 'Test Title' ) );
    574584                $this->assertInternalType( 'int', $blog_id );
    575585
    576586                $test_action_counter = 0;
    class Tests_MS extends WP_UnitTestCase { 
    939949                $site = get_current_site();
    940950
    941951                $info = wp_upload_dir();
    942                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
     952                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
    943953                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    944954                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    945955                $this->assertEquals( '', $info['error'] );
    class Tests_MS extends WP_UnitTestCase { 
    949959
    950960                switch_to_blog( $blog_id );
    951961                $info = wp_upload_dir();
    952                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );
     962                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );
    953963                $this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['path'] );
    954964                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    955965                $this->assertEquals( '', $info['error'] );
    956966                restore_current_blog();
    957967
    958968                $info = wp_upload_dir();
    959                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
     969                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
    960970                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    961971                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    962972                $this->assertEquals( '', $info['error'] );
    class Tests_MS extends WP_UnitTestCase { 
    967977                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    968978                $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );
    969979                $info = wp_upload_dir();
    970                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
     980                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
    971981                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    972982                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    973983                $this->assertEquals( '', $info['error'] );
    class Tests_MS extends WP_UnitTestCase { 
    9981008                        'user_login' => $spam_username,
    9991009                ) );
    10001010                update_user_status( $spam_user_id, 'spam', '1' );
    1001                
     1011
    10021012                $this->assertTrue( is_user_spammy( $spam_username ) );
    10031013                $this->assertFalse( is_user_spammy( 'testuser1' ) );
    10041014        }