Make WordPress Core

Changeset 677 in tests


Ignore:
Timestamp:
04/12/2012 05:02:12 PM (15 years ago)
Author:
nacin
Message:

Introduce a _destroy_uploads() method for WPTestCase to wipe the uploads folder when appropriate. Additional tests may need to call this still. props kurtypayne, see #33.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_post.php

    r675 r677  
    449449                update_option('thumbnail_size_w', 150);
    450450                update_option('thumbnail_size_h', 150);
     451
     452                $this->_destroy_uploads();
    451453        }
    452454
  • wp-testlib/base.php

    r675 r677  
    409409        }
    410410
     411        function _destroy_uploads() {
     412                $uploads = wp_upload_dir();
     413                foreach ( scandir( $uploads['basedir'] ) as $file )
     414                        _rmdir( $uploads['basedir'] . '/' . $file );
     415        }
     416
    411417        /**
    412418         * Checks if track ticket #$ticket_id is resolved
    … …  
    647653                wp_ob_end_flush_all();
    648654                parent::tearDown();
    649                 // delete any users that were created during tests
     655                // delete any users and uploads that were created during tests
    650656                $this->_destroy_users();
     657                $this->_destroy_uploads();
    651658
    652659                remove_filter( 'pre_option_enable_xmlrpc', '__return_true' );
  • wp-testlib/utils.php

    r561 r677  
    335335}
    336336
     337function _rmdir( $path ) {
     338        if ( in_array(basename( $path ), array( '.', '..' ) ) ) {
     339                return;
     340        } elseif ( is_file( $path ) ) {
     341                unlink( $path );
     342        } elseif ( is_dir( $path ) ) {
     343                foreach ( scandir( $path ) as $file )
     344                        _rmdir( $path . '/' . $file );
     345                rmdir( $path );
     346        }
     347}
     348
    337349?>
Note: See TracChangeset for help on using the changeset viewer.