Skip to content

Increase test coverage#8316

Open
Copilot wants to merge 6 commits into
developfrom
copilot/featureincrease-test-coverage-api-integration
Open

Increase test coverage#8316
Copilot wants to merge 6 commits into
developfrom
copilot/featureincrease-test-coverage-api-integration

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

I was trying to ask copilot to create a PR for this issue: #8315 but he added more tests to what we have on develop so I fixed them and it doesn't hurt having it into develop directly and I'll start another PR for adding more test coverage for API integration PR.

  • User::get_currency()
  • User::is_rocket_insights_addon_active()
  • User::is_rocket_insights_free_active()
  • User::get_rocket_insights_addon_sku_active()
  • RemoteSettings::is_rocket_insights_remote_setting_enabled()
  • RemoteSettingsClient::get_remote_settings_data() unit + integration ✓
  • Currency::get_symbol() / is_euro() / format_price_with_currency_symbol()
  • User::get_rocket_insights_license_expiration()
  • User::get_rocket_insights_addon_upgrade_skus()
  • User::get_rocket_insights_addon_btn_text()
  • User::get_rocket_insights_addon_btn_url()
  • User::get_rocket_insights_addon_limit()
  • User::get_rocket_insights_addon_subtitle()
  • User::get_rocket_insights_addon_billing()
  • User::get_rocket_insights_addon_highlights()
  • User::has_rocket_insights_addon_promo()
  • User::get_rocket_insights_addon_price()
  • User::get_rocket_insights_addon_promo_price()
  • User::get_rocket_insights_addon_promo_name()
  • User::get_rocket_insights_addon_promo_billing()

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 18, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.22% coverage variation

Metric Results
Coverage variation +0.22% coverage variation (-0.10%)
Diff coverage 100.00% diff coverage (50.00%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d3f6e54) Report Missing Report Missing Report Missing
Head commit (52d3adc) 43092 (+0) 19927 (+93) 46.24% (+0.22%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#8316) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI and others added 2 commits May 18, 2026 23:49
Agent-Logs-Url: https://github.com/wp-media/wp-rocket/sessions/3aa33159-615a-4459-a794-e82b26c5e20b

Co-authored-by: wordpressfan <146129302+wordpressfan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/wp-media/wp-rocket/sessions/3aa33159-615a-4459-a794-e82b26c5e20b

Co-authored-by: wordpressfan <146129302+wordpressfan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit and integration tests for API integration Add unit and integration tests for API integration (remote settings, currency, user methods) May 18, 2026
Copilot AI requested a review from wordpressfan May 18, 2026 23:52
Agent-Logs-Url: https://github.com/wp-media/wp-rocket/sessions/253474cc-6ffc-4849-be23-ac17e532f2fc

Co-authored-by: wordpressfan <146129302+wordpressfan@users.noreply.github.com>
@wordpressfan wordpressfan changed the title Add unit and integration tests for API integration (remote settings, currency, user methods) Increase test coverage May 19, 2026
@wordpressfan wordpressfan marked this pull request as ready for review May 19, 2026 06:13
Copilot AI review requested due to automatic review settings May 19, 2026 06:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR increases automated test coverage for the License/API “Rocket Insights” integration layer by adding a broad set of unit fixtures + test cases (and one integration test), plus a small hardening change in User::get_rocket_insights_addon_btn_url().

Changes:

  • Added unit tests (with fixtures) covering User, RemoteSettings, RemoteSettingsClient, and Currency behaviors.
  • Added an integration test for RemoteSettingsClient::get_remote_settings_data() using transient + HTTP preemption scenarios.
  • Updated User::get_rocket_insights_addon_btn_url() to use rocket_get_constant( 'WP_ROCKET_PLUGIN_SLUG' ) instead of a direct constant reference.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
inc/Engine/License/API/User.php Uses rocket_get_constant() for the plugin slug when building the Rocket Insights upgrade URL.
tests/Integration/inc/Engine/License/API/RemoteSettingsClientGetRemoteSettingsData.php Integration coverage for cached/timeout/HTTP-response paths of remote settings retrieval.
tests/Fixtures/inc/Engine/License/API/CurrencyFormatPriceWithCurrencySymbol.php Fixture data for formatting prices with currency symbols (span wrapping/spacing cases).
tests/Fixtures/inc/Engine/License/API/CurrencyGetSymbol.php Fixture data for currency symbol mapping cases.
tests/Fixtures/inc/Engine/License/API/CurrencyIsEuro.php Fixture data for Currency::is_euro() cases.
tests/Fixtures/inc/Engine/License/API/RemoteSettingsClientGetRemoteSettingsData.php Fixture data for remote settings client cached/timeout/error/success paths.
tests/Fixtures/inc/Engine/License/API/RemoteSettingsIsRemoteSettingEnabled.php Fixture data for enabled/disabled/missing remote-setting flag cases.
tests/Fixtures/inc/Engine/License/API/User/getCurrency.php Fixture data for currency defaults and explicit currency values.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonBilling.php Fixture data for addon billing text retrieval/translation behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonBtnText.php Fixture data for addon button label retrieval/translation behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonBtnUrl.php Fixture data for addon button URL behavior, including dashboard URL query arg.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonHighlights.php Fixture data for addon highlights retrieval + translation behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonLimit.php Fixture data for addon plan limit behavior and defaults.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonPrice.php Fixture data for addon price retrieval and missing-data behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonPromoBilling.php Fixture data for promo billing retrieval + translation behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonPromoName.php Fixture data for promo name retrieval + translation behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonPromoPrice.php Fixture data for promo price retrieval and expiry checks.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonSkuActive.php Fixture data for active addon SKU selection and defaults.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonSubtitle.php Fixture data for subtitle retrieval + translation behavior.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsAddonUpgradeSkus.php Fixture data for upgrade SKU list retrieval and missing-data cases.
tests/Fixtures/inc/Engine/License/API/User/getRocketInsightsLicenseExpiration.php Fixture data for addon license expiration retrieval and casting behavior.
tests/Fixtures/inc/Engine/License/API/User/hasRocketInsightsAddonPromo.php Fixture data for promo presence/expiry edge cases.
tests/Fixtures/inc/Engine/License/API/User/isRocketInsightsAddonActive.php Fixture data for paid-vs-free SKU detection.
tests/Fixtures/inc/Engine/License/API/User/isRocketInsightsFreeActive.php Fixture data for free SKU detection.
tests/Unit/inc/Engine/License/API/CurrencyFormatPriceWithCurrencySymbol.php Unit test for Currency::format_price_with_currency_symbol().
tests/Unit/inc/Engine/License/API/CurrencyGetSymbol.php Unit test for Currency::get_symbol().
tests/Unit/inc/Engine/License/API/CurrencyIsEuro.php Unit test for Currency::is_euro().
tests/Unit/inc/Engine/License/API/RemoteSettingsClientGetRemoteSettingsData.php Unit test for remote settings client behavior (HTTP success/failure + timeout transients).
tests/Unit/inc/Engine/License/API/RemoteSettingsIsRemoteSettingEnabled.php Unit test for RemoteSettings::is_rocket_insights_remote_setting_enabled().
tests/Unit/inc/Engine/License/API/User/getCurrency.php Unit test for User::get_currency().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonBilling.php Unit test for User::get_rocket_insights_addon_billing().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonBtnText.php Unit test for User::get_rocket_insights_addon_btn_text().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonBtnUrl.php Unit test for User::get_rocket_insights_addon_btn_url().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonHighlights.php Unit test for User::get_rocket_insights_addon_highlights().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonLimit.php Unit test for User::get_rocket_insights_addon_limit().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonPrice.php Unit test for User::get_rocket_insights_addon_price().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonPromoBilling.php Unit test for User::get_rocket_insights_addon_promo_billing().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonPromoName.php Unit test for User::get_rocket_insights_addon_promo_name().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonPromoPrice.php Unit test for User::get_rocket_insights_addon_promo_price().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonSkuActive.php Unit test for User::get_rocket_insights_addon_sku_active().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonSubtitle.php Unit test for User::get_rocket_insights_addon_subtitle().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsAddonUpgradeSkus.php Unit test for User::get_rocket_insights_addon_upgrade_skus().
tests/Unit/inc/Engine/License/API/User/getRocketInsightsLicenseExpiration.php Unit test for User::get_rocket_insights_license_expiration().
tests/Unit/inc/Engine/License/API/User/hasRocketInsightsAddonPromo.php Unit test for User::has_rocket_insights_addon_promo().
tests/Unit/inc/Engine/License/API/User/isRocketInsightsAddonActive.php Unit test for User::is_rocket_insights_addon_active().
tests/Unit/inc/Engine/License/API/User/isRocketInsightsFreeActive.php Unit test for User::is_rocket_insights_free_active().

Comment on lines +15 to +16
class GetRocketInsightsAddonBtnUrl extends TestCase {
use StubTrait;
Comment on lines +17 to +19
class RemoteSettingsClientGetRemoteSettingsData extends TestCase {
use StubTrait;
private $client;
Comment on lines +14 to +16
class RemoteSettingsClientGetRemoteSettingsData extends TestCase {
use StubTrait;
private static $client;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants