Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#37090 closed enhancement (fixed)

Unit test for wp_get_http_headers

Reported by: borgesbruno's profile borgesbruno Owned by: rmccue's profile 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 8 years ago.
37090.unit-tests.diff (2.9 KB) - added by jipmoors 8 years ago.
Unit tests instead of acceptance tests

Download all attachments as: .zip

Change History (11)

8 years ago

#1 @borgesbruno
8 years ago

  • Keywords has-patch has-unit-tests added

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

  • Description modified (diff)

#4 @jipmoors
8 years ago

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

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

8 years ago

Unit tests instead of acceptance tests

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

8 years ago

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