Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#33 closed defect (fixed)

Fix failed tests in WPTestAttachments

Reported by: kurtpayne Owned by:
Milestone: Fix Existing Tests Priority: normal
Component: Test Framework Keywords: attachments


Uploaded files are not being removed between tests. When new files are uploaded in subsequent tests, their names are incremented by wp_unique_filename(), and this throws off the assertions.

This fix can be implemented in just WPTestAttachments::tearDown() but we should consider putting it in WPTestCase::tearDown() so it's effective for all tests.

Attachments (2)

testlib_base.php.patch (592 bytes) - added by kurtpayne 6 years ago.
Reset uploads in WPTestCase::tearDown
rmdir.patch (1.6 KB) - added by kurtpayne 6 years ago.

Download all attachments as: .zip

Change History (9)

6 years ago

Reset uploads in WPTestCase::tearDown

#1 @nacin
6 years ago

Perhaps just scandir() and unlink() will be enough. WP_Filesystem() could potentially trigger FTP stuff, we just want the direct methods.

#2 @nacin
6 years ago

Also, I think this is too heavy for WPTestCase::tearDown(). We should place it specifically in the WPTestAttachments::tearDown().

6 years ago

#3 @kurtpayne
6 years ago

Patch attached for a recursive delete that does not rely on WP_Filesystem(). It's been targeted to just the tests that call wp_upload_bits().

#4 @nacin
6 years ago

Looks good. I think it would make sense to wrap this into $this->_destroy_attachments() or $this->destroy/empty_uploads(), similar to [675].

#5 @nacin
6 years ago

(In [677]) 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.

#6 @nacin
6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [678]) Destroy the contents of the uploads folder in TestUploadFunctions. fixes #33.

#7 @nacin
6 years ago

(In [679]) rmdir foo/ which is created in test_upload_dir_relative(). see #33.

Note: See TracTickets for help on using tickets.