WordPress.org

Make WordPress Core

Changeset 800 in tests


Ignore:
Timestamp:
06/30/12 20:21:35 (22 months ago)
Author:
nacin
Message:

Port test_uploads.php. fixes #70. fixes #27.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-testcase/test_uploads.php

    r680 r800  
    11<?php 
    22 
    3 // test various functions used by the uploader 
    43 
    5 class TestUploadFunctions extends WPTestCase { 
     4/** 
     5 * @group upload 
     6 * @group media 
     7 */ 
     8class TestUploadFunctions extends WP_UnitTestCase { 
    69 
    7     var $siteurl = 'http://example.com/foo'; 
     10    var $siteurl; 
    811 
    912    function setUp() { 
     
    1215 
    1316        parent::setUp(); 
    14         update_option( 'siteurl', $this->siteurl ); 
     17        return; 
    1518        // system defaults 
    1619        update_option( 'upload_path', 'wp-content/uploads' ); 
     
    2326 
    2427        // Remove year/month folders created by wp_upload_dir(). 
    25         $this->_destroy_uploads(); 
     28        $uploads = wp_upload_dir();  
     29        foreach ( scandir( $uploads['basedir'] ) as $file ) 
     30            _rmdir( $uploads['basedir'] . '/' . $file );  
    2631        _rmdir( ABSPATH . 'foo/' ); 
    27     } 
    28  
    29     // See #UT27 
    30     function _maybe_absolute_uploads_url( $url ) { 
    31         if ( '/wp-content' == WP_CONTENT_URL ) 
    32             return $url; 
    33  
    34         return $this->siteurl . $url; 
    3532    } 
    3633 
     
    3835        // wp_upload_dir() with default parameters 
    3936        $info = wp_upload_dir(); 
    40         $this->assertEquals( $this->_maybe_absolute_uploads_url( '/wp-content/uploads/' ) . gmstrftime('%Y/%m'), $info['url'] ); 
     37        $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 
    4138        $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 
    4239        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
     
    4845        update_option( 'upload_path', 'foo/bar' ); 
    4946        $info = wp_upload_dir(); 
    50         $this->assertEquals( $this->siteurl . '/foo/bar/' . gmstrftime('%Y/%m'), $info['url'] ); 
     47        $this->assertEquals( get_option( 'siteurl' ) . '/foo/bar/' . gmstrftime('%Y/%m'), $info['url'] ); 
    5148        $this->assertEquals( ABSPATH . 'foo/bar/' . gmstrftime('%Y/%m'), $info['path'] ); 
    5249        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
     
    7067        update_option( 'uploads_use_yearmonth_folders', 0 ); 
    7168        $info = wp_upload_dir(); 
    72         $this->assertEquals( $this->_maybe_absolute_uploads_url( '/wp-content/uploads' ), $info['url'] ); 
     69        $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/uploads', $info['url'] ); 
    7370        $this->assertEquals( ABSPATH . 'wp-content/uploads', $info['path'] ); 
    7471        $this->assertEquals( '', $info['subdir'] ); 
     
    8986        update_option('upload_path', ''); 
    9087        $info = wp_upload_dir(); 
    91         $this->assertEquals( $this->_maybe_absolute_uploads_url( '/wp-content/uploads/' ) . gmstrftime('%Y/%m'), $info['url'] ); 
     88        $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 
    9289        $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 
    9390        $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 
Note: See TracChangeset for help on using the changeset viewer.