mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
🧪 Fix the DisabledFundingSourcesTest test
This commit is contained in:
parent
602efee944
commit
0de1d21a76
1 changed files with 64 additions and 3 deletions
|
@ -32,7 +32,7 @@ class DisabledFundingSourcesTest extends TestCase
|
|||
{
|
||||
$this->dcc_configuration->shouldReceive('is_enabled')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('use_acdc')->andReturn(true);
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration);
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration, 'US');
|
||||
|
||||
$this->setExpectations();
|
||||
$this->setWcPaymentGateways();
|
||||
|
@ -50,7 +50,7 @@ class DisabledFundingSourcesTest extends TestCase
|
|||
{
|
||||
$this->dcc_configuration->shouldReceive('is_enabled')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('use_acdc')->andReturn(true);
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration);
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration, 'US');
|
||||
|
||||
$this->setExpectations();
|
||||
$this->setWcPaymentGateways();
|
||||
|
@ -71,7 +71,8 @@ class DisabledFundingSourcesTest extends TestCase
|
|||
'paypal' => 'PayPal',
|
||||
'foo' => 'Bar',
|
||||
],
|
||||
$this->dcc_configuration
|
||||
$this->dcc_configuration,
|
||||
'US'
|
||||
);
|
||||
|
||||
$this->setExpectations();
|
||||
|
@ -82,6 +83,66 @@ class DisabledFundingSourcesTest extends TestCase
|
|||
$this->assertEquals(['card', 'foo'], $sut->sources('checkout-block'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Mexico-specific logic: BCDC enabled should not disable card funding
|
||||
*/
|
||||
public function test_mexico_bcdc_enabled_does_not_disable_card_funding()
|
||||
{
|
||||
$this->dcc_configuration->shouldReceive('is_enabled')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('use_acdc')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('is_bcdc_enabled')->andReturn(true);
|
||||
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration, 'MX');
|
||||
|
||||
$this->setExpectations();
|
||||
$this->setWcPaymentGateways();
|
||||
|
||||
when('is_checkout')->justReturn(true);
|
||||
|
||||
// For Mexico with BCDC enabled, card should not be in disabled funding sources
|
||||
$this->assertEquals([], $sut->sources('checkout-block'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Mexico-specific logic: BCDC disabled should disable card funding
|
||||
*/
|
||||
public function test_mexico_bcdc_disabled_disables_card_funding()
|
||||
{
|
||||
$this->dcc_configuration->shouldReceive('is_enabled')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('use_acdc')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('is_bcdc_enabled')->andReturn(false);
|
||||
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration, 'MX');
|
||||
|
||||
$this->setExpectations();
|
||||
$this->setWcPaymentGateways();
|
||||
|
||||
when('is_checkout')->justReturn(true);
|
||||
|
||||
// For Mexico with BCDC disabled, card should be in disabled funding sources
|
||||
$this->assertEquals(['card'], $sut->sources('checkout-block'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test non-Mexico country behavior remains unchanged
|
||||
*/
|
||||
public function test_non_mexico_country_behavior_unchanged()
|
||||
{
|
||||
$this->dcc_configuration->shouldReceive('is_enabled')->andReturn(true);
|
||||
$this->dcc_configuration->shouldReceive('use_acdc')->andReturn(true);
|
||||
// BCDC method should not be called for non-Mexico countries
|
||||
|
||||
$sut = new DisabledFundingSources($this->settings, [], $this->dcc_configuration, 'CA');
|
||||
|
||||
$this->setExpectations();
|
||||
$this->setWcPaymentGateways();
|
||||
|
||||
when('is_checkout')->justReturn(true);
|
||||
|
||||
// For non-Mexico countries, existing logic applies
|
||||
$this->assertEquals(['card'], $sut->sources('checkout-block'));
|
||||
}
|
||||
|
||||
private function setExpectations(
|
||||
array $disabledFundings = [],
|
||||
bool $dccEnambled = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue