WordPress.org

Make WordPress Core

#37090 closed enhancement (fixed)

Unit test for wp_get_http_headers

Reported by: borgesbruno Owned by: rmccue
Milestone: 4.6 Priority: normal
Severity: normal Version:
Component: HTTP API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description (last modified by swissspidy)

I've wrote some tests to improve the code coverage, this special one needs to do an external request to get the headers and check whether is a valid or not response header.

This is the second ticket regarded about this duty, the first one is in #37073, following the @rmccue recommendation I've created a new ticket only with the tests

Attachments (2)

37090.diff (1.1 KB) - added by borgesbruno 20 months ago.
37090.unit-tests.diff (2.9 KB) - added by jipmoors 19 months ago.
Unit tests instead of acceptance tests

Download all attachments as: .zip

Change History (11)

@borgesbruno
20 months ago

#1 @borgesbruno
20 months ago

  • Keywords has-patch has-unit-tests added

#2 @DrewAPicture
20 months ago

  • Component changed from General to HTTP API
  • Milestone changed from Awaiting Review to 4.6
  • Owner set to rmccue
  • Status changed from new to reviewing

#3 @swissspidy
20 months ago

  • Description modified (diff)

#4 @jipmoors
19 months ago

I have created a new patch which has unit tests instead of acceptance tests.

Last edited 19 months ago by jipmoors (previous) (diff)

@jipmoors
19 months ago

Unit tests instead of acceptance tests

#5 @swissspidy
19 months ago

@jipmoors That's a known issue due to some changes to the trac database yesterday. You should be able to upload it soon-ish.

#6 @jipmoors
19 months ago

These acceptance and unit tests can be complementary.

I can understand internals would be changed at some point so unit tests would fail, so I am thinking about writing unit tests to cover the WP_Http class, which is used to supply the actual fetching functionality.

#7 @borgesbruno
19 months ago

This is also a good approach @jipmoors use a mock instead of a real http request, like you said can be complementary

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


19 months ago

#9 @ocean90
19 months ago

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

In 37907:

HTTP: Add unit tests for wp_get_http_headers() and wp_remote_retrieve_headers().

Props borgesbruno, jipmoors.
Fixes #37090.

Note: See TracTickets for help on using tickets.