WordPress.org

Make WordPress Core

Changeset 1080 in tests


Ignore:
Timestamp:
10/11/12 17:47:45 (18 months ago)
Author:
ryan
Message:

Test wp_upload_dir() with switch_to_blog().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r1078 r1080  
    838838        restore_current_blog(); 
    839839    } 
     840 
     841    function test_switch_upload_dir() { 
     842        $this->assertTrue( is_main_site() ); 
     843 
     844        $site = get_current_site(); 
     845 
     846        $info = wp_upload_dir(); 
     847        $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 
     848        $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 
     849        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
     850        $this->assertEquals( '', $info['error'] ); 
     851 
     852        $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 
     853        $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id ) ); 
     854 
     855        switch_to_blog( $blog_id ); 
     856        $info = wp_upload_dir(); 
     857        $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] ); 
     858        $this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['path'] ); 
     859        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
     860        $this->assertEquals( '', $info['error'] ); 
     861        restore_current_blog(); 
     862 
     863        $info = wp_upload_dir(); 
     864        $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 
     865        $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 
     866        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
     867        $this->assertEquals( '', $info['error'] ); 
     868    } 
    840869} 
    841870 
Note: See TracChangeset for help on using the changeset viewer.