-
Notifications
You must be signed in to change notification settings - Fork 926
Add integration tests for the analytics adapter #22102
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
Open
leonidasmi
wants to merge
17
commits into
trunk
Choose a base branch
from
481-add-unitintegration-tests-for-the-analytics-adapter
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,238
−141
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
01b38ae
Start adding tests for the analytics adapter
leonidasmi e970bc3
Merge branch '580-add-integration-tests-for-search-console-adapter' i…
leonidasmi 1fe3a15
Run analytics adapter tests only on PHP 7.4 and later
leonidasmi db7a7a6
Add more tests for the analytics adapter
leonidasmi 03d9c7b
Add the rest of the tests for the analytics adapter
leonidasmi 7f9e17c
Add codeCoverageIgnore
leonidasmi 8315c25
Fix coverage annotations
leonidasmi b3d9ac2
Rework search console and analytics 4 calls to internally use a rest …
thijsoo 1f9d130
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into 493-do-ht…
thijsoo be32dc6
Mark test skipped.
thijsoo 5e3b979
Add api call abstraction
thijsoo 7429ace
Merge branch '493-do-http-requests-to-site-kit-endpoints-when-on-our-…
leonidasmi 0e46ec9
Add testing case for is_connected(), as per CR feedback
leonidasmi f3d7061
Update tests now that we do requests to Site Kit's REST endpoints ins…
leonidasmi a04d212
Skip test temporarily much like how we're doing with the other failed…
leonidasmi 5e5d7ff
Remove test for not being connected because is_connected() is going t…
leonidasmi 976d146
Apply CR feedback about naming of test classes
leonidasmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/dashboard/infrastructure/analytics-4/site-kit-analytics-4-api-call.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong | ||
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded | ||
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Analytics_4; | ||
|
||
use WP_REST_Request; | ||
use WP_REST_Response; | ||
|
||
/** | ||
* Class that hold the code to do the REST call to the Site Kit api. | ||
* | ||
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded | ||
*/ | ||
class Site_Kit_Analytics_4_Api_Call { | ||
|
||
/** | ||
* The Analytics 4 API route path. | ||
*/ | ||
private const ANALYTICS_DATA_REPORT_ROUTE = '/google-site-kit/v1/modules/analytics-4/data/report'; | ||
|
||
/** | ||
* Runs the internal REST api call. | ||
* | ||
* @param array<string, array<string, string>> $api_parameters The api parameters. | ||
* | ||
* @return WP_REST_Response | ||
*/ | ||
public function do_request( array $api_parameters ): WP_REST_Response { | ||
$request = new WP_REST_Request( 'GET', self::SEARCH_CONSOLE_DATA_SEARCH_ANALYTICS_ROUTE ); | ||
$request->set_query_params( $api_parameters ); | ||
return \rest_do_request( $request ); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/dashboard/infrastructure/search-console/site-kit-search-console-api-call.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong | ||
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded | ||
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Search_Console; | ||
|
||
use WP_REST_Request; | ||
use WP_REST_Response; | ||
|
||
/** | ||
* Class that hold the code to do the REST call to the Site Kit api. | ||
* | ||
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded | ||
*/ | ||
class Site_Kit_Search_Console_Api_Call { | ||
|
||
/** | ||
* The search analytics API route path. | ||
*/ | ||
private const SEARCH_CONSOLE_DATA_SEARCH_ANALYTICS_ROUTE = '/google-site-kit/v1/modules/search-console/data/searchanalytics'; | ||
|
||
/** | ||
* Runs the internal REST api call. | ||
* | ||
* @param array<string, array<string, string>> $api_parameters The api parameters. | ||
* | ||
* @return WP_REST_Response | ||
*/ | ||
public function do_request( array $api_parameters ): WP_REST_Response { | ||
$request = new WP_REST_Request( 'GET', self::SEARCH_CONSOLE_DATA_SEARCH_ANALYTICS_ROUTE ); | ||
$request->set_query_params( $api_parameters ); | ||
return \rest_do_request( $request ); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.