You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The initial implementation of the test coverage for the fpm-server-requirement-status (see #9632) involved mocking the is_endpoint_healthy() protected method of the REST_First_Party_Mode_Controller, due to difficulty testing the code contained within the method.
Notably, although it's possible to mock file_get_contents(), it doesn't appear possible to mock the $http_response_header that gets set locally in the file_get_contents() caller's scope with off the shelf tooling.
We should improve the test coverage to ensure the code contained in is_endpoint_healthy() is covered. Possible angles include:
Refactoring REST_First_Party_Mode_Controller so we pass in say a Guzzle client instance, or our own wrapper to file_get_contents(), and use that rather than calling file_get_contents() directly, allowing us to pass in a mock client during testing and avoid mocking is_endpoint_healthy().
Adding E2E test coverage for the endpoint. This comes with its own challenges, notably mocking the health check to https://g-1234.fps.goog/mpath/healthy to avoid calling the real Google service from our E2E tests. It looks possible, but would involve some structural changes to our E2E test environment; this was explored during the implementation of 9632, see Add fpm-server-requirement-status E2E test (draft). #9707. A more practical approach requiring less structural changes would be to provide filters for the health check URLs so we could override them during testing. However, the REST_First_Party_Mode_Controller described above is probably the best way to proceed here.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Test Coverage
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered:
Feature Description
The initial implementation of the test coverage for the
fpm-server-requirement-status
(see #9632) involved mocking theis_endpoint_healthy()
protected method of theREST_First_Party_Mode_Controller
, due to difficulty testing the code contained within the method.Notably, although it's possible to mock
file_get_contents()
, it doesn't appear possible to mock the$http_response_header
that gets set locally in thefile_get_contents()
caller's scope with off the shelf tooling.site-kit-wp/tests/phpunit/integration/Core/Tags/First_Party_Mode/REST_First_Party_Mode_ControllerTest.php
Lines 235 to 241 in 54f900c
We should improve the test coverage to ensure the code contained in
is_endpoint_healthy()
is covered. Possible angles include:REST_First_Party_Mode_Controller
so we pass in say a Guzzle client instance, or our own wrapper tofile_get_contents()
, and use that rather than callingfile_get_contents()
directly, allowing us to pass in a mock client during testing and avoid mockingis_endpoint_healthy()
.https://g-1234.fps.goog/mpath/healthy
to avoid calling the real Google service from our E2E tests. It looks possible, but would involve some structural changes to our E2E test environment; this was explored during the implementation of 9632, see Addfpm-server-requirement-status
E2E test (draft). #9707. A more practical approach requiring less structural changes would be to provide filters for the health check URLs so we could override them during testing. However, theREST_First_Party_Mode_Controller
described above is probably the best way to proceed here.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Test Coverage
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: