From 35fbe42733cf4b71789326676903ea171940a838 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Wed, 12 Jul 2023 14:57:57 +0100 Subject: [PATCH] Refactor WooCommerce\PayPalCommerce\Onboarding\Exception\RuntimeException to \RuntimeException Refactor to use add_query_arg in append_onboarding_token --- .../src/Repository/PartnerReferralsData.php | 5 ++--- .../src/Exception/RuntimeException.php | 18 ------------------ .../src/Helper/OnboardingUrl.php | 2 +- .../src/Settings/SettingsListener.php | 2 +- .../Onboarding/Helper/OnboardingUrlTest.php | 2 +- 5 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 modules/ppcp-onboarding/src/Exception/RuntimeException.php diff --git a/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php b/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php index fd93e57be..af8bae174 100644 --- a/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php +++ b/modules/ppcp-api-client/src/Repository/PartnerReferralsData.php @@ -136,9 +136,8 @@ class PartnerReferralsData { * @return array */ public function append_onboarding_token( array $data, string $token ): array { - $separator = strpos( $data['partner_config_override']['return_url'], '?' ) === false ? '?' : '&'; - - $data['partner_config_override']['return_url'] .= $separator . 'ppcpToken=' . $token; + $data['partner_config_override']['return_url'] = + add_query_arg( 'ppcpToken', $token, $data['partner_config_override']['return_url'] ); return $data; } } diff --git a/modules/ppcp-onboarding/src/Exception/RuntimeException.php b/modules/ppcp-onboarding/src/Exception/RuntimeException.php deleted file mode 100644 index fc14fc94f..000000000 --- a/modules/ppcp-onboarding/src/Exception/RuntimeException.php +++ /dev/null @@ -1,18 +0,0 @@ -is_valid_site_request() ) { return; } diff --git a/tests/PHPUnit/Onboarding/Helper/OnboardingUrlTest.php b/tests/PHPUnit/Onboarding/Helper/OnboardingUrlTest.php index 63b495792..5dadd2c79 100644 --- a/tests/PHPUnit/Onboarding/Helper/OnboardingUrlTest.php +++ b/tests/PHPUnit/Onboarding/Helper/OnboardingUrlTest.php @@ -5,7 +5,7 @@ namespace WooCommerce\PayPalCommerce\Onboarding\Helper; use PHPUnit\Framework\TestCase; use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache; -use WooCommerce\PayPalCommerce\Onboarding\Exception\RuntimeException; +use RuntimeException; use function Brain\Monkey\Functions\when; class OnboardingUrlTest extends TestCase