-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests/remove network dependent #3541
Conversation
@@ -85,159 +82,6 @@ public function test_get_plugins_authorized() { | |||
$this->assertEquals( $expected_jetpack_info, $data['jetpack'] ); | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik, all these tests are not making any requests. server->dispatch
is emulating the server receiving a request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the way to test Rest API endpoints without needing http requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not about testing the REST API endpoints. The endpoint handler is making requests to the plugin repository to fetch plugin code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha
'Emails are empty until configured.' | ||
); | ||
self::assertFalse( | ||
Emails::can_send_email( 'test-email-config' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we short circuit wp_mail
to make sure no requests are made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not about wp_mail
. The issue with this test is that it installed newspack-newsletters
from the plugin repository. I've replaced it with a mock of Newspack_Newsletters
class, and to simplify removed the test assertions related to the plugin being inactive. This is not ideal, I know, but I don't think making it ideal is worth the effort.
Hey @, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to it to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
🎉 This PR is included in version 5.8.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 5.8.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Removes and adjusts unit tests, so they are not network-dependent. Unit tests should not rely on remote services and servers.
How to test the changes in this Pull Request:
Other information: