[wp-trac] [WordPress Trac] #38264: Tests: Uploads aren't deleted after running individual tests
WordPress Trac
noreply at wordpress.org
Thu Sep 7 20:00:01 UTC 2017
#38264: Tests: Uploads aren't deleted after running individual tests
---------------------------+------------------
Reporter: johnbillion | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.9
Component: Media | Version:
Severity: normal | Resolution:
Keywords: needs-testing | Focuses:
---------------------------+------------------
Changes (by atanasangelovdev):
* keywords: needs-patch needs-unit-tests => needs-testing
Comment:
I spent some time investigating this and what I found was that the test in
question does not clean up it's uploaded file but since it is ran
alongside other tests that remove all uploads it happens to work.
My patch resolves the issue but I don't really like that it deletes a post
that will end up deleted due to database transactions/wiping anyway (this
may not really be something worth thinking about - let me know).
On a related note, Tests_Post_Thumbnail_Template suffers from the same
issue - should I refresh the patch including a fix for it as well or
should that be posted in a separate ticket with it's own patch?
---
Other (failed) attemps:
- Since the file was uploaded in `wpSetUpBeforeClass`, my first attempt
was to use `remove_added_uploads()` in `wpTearDownAfterClass` which was
unsuccessful since `remove_added_uploads` is an instance method while
`wpTearDownAfterClass` is static (even if I add a static equivalent it
calls `$this->rmdir()` which calls `$this->files_in_dir()` and down the
rabbit hole we go ...)
- My second attempt included moving the attachment creation to setUp and
it's deletion on tearDown which as you would probably guess led to a slow
test.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38264#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list