Skip to content

Commit 41cfbfa

Browse files
committed
🧪 Update PartnersEndpointTest and fix SellerStatusFilter docblocks
1 parent be07534 commit 41cfbfa

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎modules/ppcp-api-client/src/Helper/SellerStatusFilter.php‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@
2323
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusCapability;
2424
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct;
2525

26+
/**
27+
* Class SellerStatusFilter
28+
*/
2629
class SellerStatusFilter {
2730

2831
/**
32+
* Complete fallback SellerStatus used when the API call fails.
33+
*
2934
* @var SellerStatus|null
3035
*/
3136
private ?SellerStatus $fallback = null;
@@ -66,6 +71,8 @@ class SellerStatusFilter {
6671
private array $removed_capabilities = array();
6772

6873
/**
74+
* Country override, or null to keep the original value.
75+
*
6976
* @var string|null
7077
*/
7178
private ?string $country_override = null;
@@ -82,10 +89,20 @@ public function set_fallback( SellerStatus $fallback ): self {
8289
return $this;
8390
}
8491

92+
/**
93+
* Returns the fallback SellerStatus, or null if none is set.
94+
*
95+
* @return SellerStatus|null
96+
*/
8597
public function get_fallback(): ?SellerStatus {
8698
return $this->fallback;
8799
}
88100

101+
/**
102+
* Whether a fallback is configured.
103+
*
104+
* @return bool
105+
*/
89106
public function has_fallback(): bool {
90107
return null !== $this->fallback;
91108
}
@@ -171,8 +188,7 @@ public function override_country( string $country ): self {
171188
* Whether any transformations have been registered.
172189
*/
173190
public function has_modifications(): bool {
174-
return $this->fallback !== null
175-
|| ! empty( $this->product_capability_additions )
191+
return ! empty( $this->product_capability_additions )
176192
|| ! empty( $this->product_capability_removals )
177193
|| ! empty( $this->removed_products )
178194
|| ! empty( $this->ensured_capabilities )

‎tests/PHPUnit/ApiClient/Endpoint/PartnersEndpointTest.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use WooCommerce\PayPalCommerce\ApiClient\Factory\SellerStatusFactory;
1414
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
1515
use WooCommerce\PayPalCommerce\ApiClient\Helper\FailureRegistry;
16+
use WooCommerce\PayPalCommerce\ApiClient\Helper\SellerStatusFilter;
1617
use WooCommerce\PayPalCommerce\TestCase;
1718
use function Brain\Monkey\Functions\expect;
1819
use function Brain\Monkey\Functions\when;
@@ -78,7 +79,7 @@ public function setUp(): void
7879
// Factory helper
7980
// -----------------------------------------------------------------------
8081

81-
private function make_endpoint(): PartnersEndpoint
82+
private function make_endpoint(?SellerStatusFilter $filter = null): PartnersEndpoint
8283
{
8384
return new PartnersEndpoint(
8485
self::HOST,
@@ -88,7 +89,8 @@ private function make_endpoint(): PartnersEndpoint
8889
self::PARTNER_ID,
8990
self::MERCHANT_ID,
9091
$this->failure_registry,
91-
$this->cache
92+
$this->cache,
93+
$filter ?? new SellerStatusFilter()
9294
);
9395
}
9496

0 commit comments

Comments
 (0)