Increase test coverage#8316
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
🟢 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%) 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.
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>
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>
There was a problem hiding this comment.
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, andCurrencybehaviors. - Added an integration test for
RemoteSettingsClient::get_remote_settings_data()using transient + HTTP preemption scenarios. - Updated
User::get_rocket_insights_addon_btn_url()to userocket_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(). |
| class GetRocketInsightsAddonBtnUrl extends TestCase { | ||
| use StubTrait; |
| class RemoteSettingsClientGetRemoteSettingsData extends TestCase { | ||
| use StubTrait; | ||
| private $client; |
| class RemoteSettingsClientGetRemoteSettingsData extends TestCase { | ||
| use StubTrait; | ||
| private static $client; |
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()✓