Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#34075 closed task (blessed) (fixed)

Consolidate methods for creating image attachments in tests

Reported by: joemcgill Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch
Focuses: Cc:


In our test suite, we have three instances of a _make_attachment() helper function for uploading a file and creating an attachment for tests. They are in tests/image/intermediate_size.php, tests/post/attachment.php, and tests/ajax/MediaElement.php.

We should replace these helper functions with a new factory method inside WP_UnitTest_Factory_For_Attachment.

Change History (6)

#1 @boonebgorges
6 years ago

Or we could just have a globally-available tool - either a method on WP_UnitTestCase, or a utils function.

This ticket was mentioned in Slack in #core by joemcgill. View the logs.

6 years ago

#3 @wonderboymusic
6 years ago

  • Type changed from enhancement to task (blessed)

#4 @wonderboymusic
6 years ago

  • Owner set to wonderboymusic
  • Status changed from new to assigned

#5 follow-up: @wonderboymusic
6 years ago

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

In 35309:

Unit Tests: consolidate the many separate implementations of _make_attachment() into a helper method on WP_UnitTestCase.

Fixes #34075.

#6 in reply to: ↑ 5 @joemcgill
6 years ago

Replying to wonderboymusic:

Was planning to circle back to this. I added the same basic helper method as WP_UnitTest_Factory_For_Attachment:create_upload_object() in 34855.

Note: See TracTickets for help on using tickets.