Skip to content

Don't mock HTTP requests for the external-http testsuite#4004

Merged
westonruter merged 4 commits intodevelopfrom
enhancement/external-http-requests
Jan 16, 2020
Merged

Don't mock HTTP requests for the external-http testsuite#4004
westonruter merged 4 commits intodevelopfrom
enhancement/external-http-requests

Conversation

@pierlon
Copy link
Copy Markdown
Contributor

@pierlon pierlon commented Dec 21, 2019

Summary

While working on #3954, an error with the Crowdsignal embed test surfaced (not pertaining to the aforementioned PR). That error should not have occurred as it would receive a mocked HTTP response body to sanitize, but due to a mishandled case in WP < 5.1 the HTTP request was not mocked (fixed in #3956). Because of this, it was discovered that Crowdsignal's embed response had been changed, causing the assertion of the expected HTML to fail.

This has brought into light the possibility of the other supported embeds returning HTML being unaccounted for and could lead to broken reports of them, while we are happily contented with the passing tests.

This PR seeks to change the way how embeds are tested by adding a new PHPUnit testsuite called external-http, which will allow the HTTP requests of these embeds to pass through unfiltered and allow for a true comparison of the expected HTML.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@googlebot googlebot added the cla: yes Signed the Google CLA label Dec 21, 2019
* @package AMP
*/

define( 'AMP_IMG_DIMENSION_TEST_INVALID_FILE', dirname( __FILE__ ) . '/assets/not-exists.png' );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored the external-http group of tests to their own class called AMP_Image_Dimension_Extract_Download_Test, which makes it easier to add and remove from test suites.

],

'url_simple' => [
'https://imgur.com/f462IUj' . PHP_EOL,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint throws a 404 so I've updated it.

@pierlon pierlon marked this pull request as ready for review January 6, 2020 18:23
@pierlon
Copy link
Copy Markdown
Contributor Author

pierlon commented Jan 6, 2020

⚠️ Rebasing with latest changes from develop.

@pierlon pierlon force-pushed the enhancement/external-http-requests branch from 2215b10 to 1f752c4 Compare January 6, 2020 18:30
@pierlon pierlon self-assigned this Jan 6, 2020
@pierlon pierlon force-pushed the enhancement/external-http-requests branch from 1f752c4 to 73c24c6 Compare January 10, 2020 06:24
@pierlon
Copy link
Copy Markdown
Contributor Author

pierlon commented Jan 16, 2020

⚠️ Rebasing with latest changes from develop to resolve merge conflict.

@pierlon pierlon force-pushed the enhancement/external-http-requests branch from 73c24c6 to 68db8b1 Compare January 16, 2020 03:08
@westonruter westonruter force-pushed the enhancement/external-http-requests branch from 1c3b965 to 68686d4 Compare January 16, 2020 23:09
@westonruter westonruter added this to the v1.5 milestone Jan 16, 2020
@westonruter westonruter merged commit 0b91f99 into develop Jan 16, 2020
@westonruter westonruter deleted the enhancement/external-http-requests branch January 16, 2020 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Signed the Google CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants