WordPress.org

Make WordPress Core

Changeset 1082 in tests


Ignore:
Timestamp:
10/15/12 15:53:37 (18 months ago)
Author:
ryan
Message:

Tests for wp_upload_dir() and blog switching. see #WP19235

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r1080 r1082  
    866866        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
    867867        $this->assertEquals( '', $info['error'] ); 
     868 
     869        update_site_option( 'ms_files_rewriting', 1 ); 
     870        ms_upload_constants(); 
     871 
     872        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 
     873        $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) ); 
     874        $info = wp_upload_dir(); 
     875        $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 
     876        $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 
     877        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
     878        $this->assertEquals( '', $info['error'] ); 
     879 
     880        switch_to_blog( $blog_id2 ); 
     881        $info2 = wp_upload_dir(); 
     882        $this->assertNotEquals( $info, $info2 ); 
     883        $this->assertEquals( get_option( 'siteurl' )  . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['url'] ); 
     884        $this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['path'] ); 
     885        $this->assertEquals( gmstrftime('/%Y/%m'), $info2['subdir'] ); 
     886        $this->assertEquals( '', $info2['error'] ); 
     887        restore_current_blog(); 
     888        update_site_option( 'ms_files_rewriting', 0 ); 
    868889    } 
    869890} 
Note: See TracChangeset for help on using the changeset viewer.