Do not remove mini-cart location for pay later

This commit is contained in:
Alex P 2023-03-01 16:17:36 +02:00
parent 8c1af84204
commit 2adc0d57e1
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 105 additions and 17 deletions

View file

@ -0,0 +1,60 @@
<?php
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
use WooCommerce\PayPalCommerce\Helper\SettingsStub;
use WooCommerce\PayPalCommerce\ModularTestCase;
class LocationsTest extends ModularTestCase
{
private $appContainer;
private $settings;
public function setUp(): void {
parent::setUp();
$this->settings = new SettingsStub([]);
$this->appContainer = $this->bootstrapModule([
'wcgateway.settings' => function () {
return $this->settings;
},
]);
}
/**
* @dataProvider payLaterButtonLocationsData
*/
public function testPayLaterButtonLocations(array $selectedLocations, array $expectedResult) {
$this->settings->set('smart_button_locations', $selectedLocations);
$result = $this->appContainer->get('wcgateway.settings.pay-later.button-locations');
self::assertEquals($expectedResult, $result);
}
public function payLaterButtonLocationsData()
{
yield [
['product', 'cart', 'checkout', 'mini-cart'],
[
'product' => 'Single Product',
'cart' => 'Cart',
'checkout' => 'Checkout',
'mini-cart' => 'Mini Cart',
],
];
yield [
['cart', 'checkout'],
[
'cart' => 'Cart',
'checkout' => 'Checkout',
],
];
yield [
[],
[],
];
}
}