WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 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
Cc:

Description

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 2 years ago.
Reset uploads in WPTestCase::tearDown
rmdir.patch (1.6 KB) - added by kurtpayne 2 years ago.

Download all attachments as: .zip

Change History (9)

kurtpayne2 years ago

Reset uploads in WPTestCase::tearDown

comment:1 nacin2 years ago

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

comment:2 nacin2 years ago

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

kurtpayne2 years ago

comment:3 kurtpayne2 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().

comment:4 nacin2 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].

comment:5 nacin2 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.

comment:6 nacin2 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.

comment:7 nacin2 years ago

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

Note: See TracTickets for help on using tickets.