From ef76ddbbfa5cb674c44f7bca35bb04fcfb943d73 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Wed, 5 Mar 2025 16:38:25 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20failing=20tests=20before?=
=?UTF-8?q?=20implementing=20new=20flag?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Repository/PartnerReferralsDataTest.php | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tests/PHPUnit/ApiClient/Repository/PartnerReferralsDataTest.php b/tests/PHPUnit/ApiClient/Repository/PartnerReferralsDataTest.php
index 51cada741..b748692de 100644
--- a/tests/PHPUnit/ApiClient/Repository/PartnerReferralsDataTest.php
+++ b/tests/PHPUnit/ApiClient/Repository/PartnerReferralsDataTest.php
@@ -109,6 +109,9 @@ class PartnerReferralsDataTest extends TestCase {
* core params present in the legacy and new UI.
*/
public function testDataStructure() : void {
+ /**
+ * Undefined subscription: Keep vaulting in first-party, but don't add the capability.
+ */
$result = $this->testee->data( [ 'PPCP' ], 'TOKEN' );
$this->dccApplies->shouldNotHaveReceived( 'for_country_currency' );
@@ -123,6 +126,37 @@ class PartnerReferralsDataTest extends TestCase {
$this->assertEquals( $expected, $result );
}
+ /**
+ * Verify new onboarding-flags that are used by the new UI.
+ */
+ public function testDataStructureWithFlags() : void {
+ /**
+ * With subscriptions: Request full vaulting features.
+ */
+ $result = $this->testee->data( [ 'PPCP' ], 'TOKEN', true );
+ $expected = $this->getBaseExpectedArray();
+
+ $expected['products'] = [ 'PPCP' ];
+ $expected['capabilities'] = [ 'PAYPAL_WALLET_VAULTING_ADVANCED' ];
+
+ $expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'FUTURE_PAYMENT';
+ $expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'][] = 'VAULT';
+
$this->assertEquals( $expected, $result );
+
+ /**
+ * No subscriptions: Also means no vaulting!
+ */
+ $result = $this->testee->data( [ 'PPCP' ], 'TOKEN', false );
+ $expected = $this->getBaseExpectedArray();
+
+ $expected['products'] = [ 'PPCP' ];
+ $expected['capabilities'] = [];
+
+ $this->assertEquals( $expected, $result );
+
+ // Double-check that the features are not present.
+ $this->assertNotContains( 'FUTURE_PAYMENT', $expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'] );
+ $this->assertNotContains( 'VAULT', $expected['operations'][0]['api_integration_preference']['rest_api_integration']['first_party_details']['features'] );
}
}