WordPress.org

Make WordPress Core

Ticket #24173: 24173.01.patch

File 24173.01.patch, 7.8 KB (added by r-a-y, 8 years ago)

Updated patch to fix WP_SITEURL

  • 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( 'WP_TESTS_PATH' ) ) {
     53                define( 'PATH_CURRENT_SITE', WP_TESTS_PATH );   
     54                $_SERVER['REQUEST_URI'] = PATH_CURRENT_SITE;
     55        } else {
     56                define( 'PATH_CURRENT_SITE', '/' );
     57        }
     58
    5259        define( 'SITE_ID_CURRENT_SITE', 1 );
    5360        define( 'BLOG_ID_CURRENT_SITE', 1 );
    54         $GLOBALS['base'] = '/';
     61        $GLOBALS['base'] = PATH_CURRENT_SITE;
    5562} else {
    5663        echo "Running as single site... To run multisite, use -c multisite.xml" . PHP_EOL;
    5764}
  • includes/install.php

    foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { 
    5050                $wpdb->$table = $prefixed_table;
    5151}
    5252
     53if ( $multisite ) {
     54        if ( defined( 'WP_TESTS_PATH' ) ) {
     55                $path = WP_TESTS_PATH;
     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 { 
    2424                        $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
    2525
    2626                        // 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' ) );
     27                        // support subdirectory installs
     28                        if ( defined( 'WP_TESTS_PATH' ) ) {
     29                                $slug = str_replace( '/', PATH_CURRENT_SITE, $details->path );
     30                        } else {
     31                                $slug = trim( $details->path, '/' );
     32                        }
     33                        $this->assertEquals( $blog_id, get_id_from_blogname( $slug ) );
     34                        $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ) );
    2935
    3036                        // get_blog_id_from_url()
    3137                        $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
    class Tests_MS extends WP_UnitTestCase { 
    352358                $blog = get_blog_details( $blog_id );
    353359                $this->assertEquals( $blog_id, $blog->blog_id );
    354360                $this->assertEquals( $current_site->domain, $blog->domain );
    355                 $this->assertEquals( '/', $blog->path );
     361                $this->assertEquals( PATH_CURRENT_SITE, $blog->path );
    356362
    357363                // Test defaulting to current blog
    358364                $this->assertEquals( $blog, get_blog_details() );
    359 
    360365                $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' ) );
     366                $blog_id = $this->factory->blog->create( array(
     367                        'user_id' => $user_id,
     368                        'path'    => PATH_CURRENT_SITE . 'test_blogname',
     369                        'title'   => 'Test Title'
     370                ) );
    362371                $this->assertInternalType( 'int', $blog_id );
    363 
    364372                $this->assertEquals( 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . 'test_blogname/', get_blogaddress_by_name('test_blogname') );
    365373
    366                 $this->assertEquals( $blog_id, get_id_from_blogname('test_blogname') );
     374                $this->assertEquals( $blog_id, get_id_from_blogname( 'test_blogname' ) );
    367375        }
    368376
    369377        function _action_counter_cb( $blog_id ) {
    class Tests_MS extends WP_UnitTestCase { 
    570578                global $test_action_counter;
    571579
    572580                $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' ) );
     581                $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => PATH_CURRENT_SITE . 'test_blogpath', 'title' => 'Test Title' ) );
    574582                $this->assertInternalType( 'int', $blog_id );
    575583
    576584                $test_action_counter = 0;
    class Tests_MS extends WP_UnitTestCase { 
    930938                $site = get_current_site();
    931939
    932940                $info = wp_upload_dir();
    933                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
     941                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
    934942                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    935943                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    936944                $this->assertEquals( '', $info['error'] );
    class Tests_MS extends WP_UnitTestCase { 
    940948
    941949                switch_to_blog( $blog_id );
    942950                $info = wp_upload_dir();
    943                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );
     951                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );
    944952                $this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['path'] );
    945953                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    946954                $this->assertEquals( '', $info['error'] );
    947955                restore_current_blog();
    948956
    949957                $info = wp_upload_dir();
    950                 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
     958                $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
    951959                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    952960                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    953961                $this->assertEquals( '', $info['error'] );
    class Tests_MS extends WP_UnitTestCase { 
    958966                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    959967                $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );
    960968                $info = wp_upload_dir();
    961                 $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'] );
    962970                $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
    963971                $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
    964972                $this->assertEquals( '', $info['error'] );
    class Tests_MS extends WP_UnitTestCase { 
    990998                ) );
    991999                update_user_status( $spam_user_id, 'spam', '1' );
    9921000               
    993                 $this->assertTrue( is_user_spammy( $spam_username ) );
     1001                $this->assertTrue( is_user_spammy( $spam_user_id ) );
    9941002                $this->assertFalse( is_user_spammy( 'testuser1' ) );
    9951003        }
    9961004
  • wp-tests-config-sample.php

    define( 'DB_COLLATE', '' ); 
    3131$table_prefix  = 'wptests_';   // Only numbers, letters, and underscores please!
    3232
    3333define( 'WP_TESTS_DOMAIN', 'example.org' );
    34 define( 'WP_TESTS_EMAIL', 'admin@example.org' );
    35 define( 'WP_TESTS_TITLE', 'Test Blog' );
     34define( 'WP_TESTS_PATH',   '/' );
     35define( 'WP_TESTS_EMAIL',  'admin@example.org' );
     36define( 'WP_TESTS_TITLE',  'Test Blog' );
    3637
    3738define( 'WP_PHP_BINARY', 'php' );
    3839