WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#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 2 years ago.
37090.unit-tests.diff (2.9 KB) - added by jipmoors 2 years ago.
Unit tests instead of acceptance tests

Download all attachments as: .zip

Change History (11)

@borgesbruno
2 years ago

#1 @borgesbruno
2 years ago

  • Keywords has-patch has-unit-tests added

#2 @DrewAPicture
2 years 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
2 years ago

  • Description modified (diff)

#4 @jipmoors
2 years ago

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

Last edited 2 years ago by jipmoors (previous) (diff)

@jipmoors
2 years ago

Unit tests instead of acceptance tests

#5 @swissspidy
2 years 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
2 years 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
2 years 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.


2 years ago

#9 @ocean90
2 years 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.