-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1167 from PrestaShopCorp/refacto/sdk-parameters-b…
…ackend-usecases Adding more ECM usecases
- Loading branch information
Showing
9 changed files
with
926 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Amount; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\AmountEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\CountryEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\CurrencyEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\ExcludedCountryEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\IntentEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\PageTypeEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\PaymentSource; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\PaymentSourceUseCase; | ||
|
||
class BlikPaymentSourceTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider invalidBlikDataProvider | ||
*/ | ||
public function testInvalidBlikPaymentSource($data) | ||
{ | ||
$paymentSource = new PaymentSource( | ||
'blik', | ||
'Blik', | ||
[ | ||
new AmountEligibilityRule($data['amount'], '1'), | ||
new CountryEligibilityRule($data['buyerCountry'], ['PL']), | ||
new CurrencyEligibilityRule($data['currency'], ['PLN']), | ||
new ExcludedCountryEligibilityRule($data['merchantCountry'], ['RU', 'JP', 'BR']), | ||
], | ||
[ | ||
new PaymentSourceUseCase( | ||
'ECM', | ||
[ | ||
new IntentEligibilityRule($data['intent'], ['CAPTURE']), | ||
new PageTypeEligibilityRule($data['pageType'], ['checkout']) | ||
] | ||
) | ||
] | ||
); | ||
} | ||
|
||
public function invalidBlikDataProvider() | ||
{ | ||
return [ | ||
[ | ||
[ | ||
'amount' => '0.99', // Invalid amount | ||
'buyerCountry' => 'PL', | ||
'currency' => 'PLN', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'FR', // Invalid buyer country | ||
'currency' => 'PLN', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'US', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '9.90', | ||
'buyerCountry' => 'PL', | ||
'currency' => 'USD', // Invalid currency | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'US', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'PL', | ||
'currency' => 'PLN', | ||
'intent' => 'AUTHORIZE', // Invalid intent | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '15', | ||
'buyerCountry' => 'PL', | ||
'currency' => 'PLN', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'JP', // Invalid merchant country | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'PL', | ||
'currency' => 'PLN', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'product' // Invalid pageType | ||
], | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Amount; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\AmountEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\CountryEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\CurrencyEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\ExcludedCountryEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\IntentEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\PageTypeEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\PaymentSource; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\PaymentSourceUseCase; | ||
|
||
class EpsPaymentSourceTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider invalidEpsDataProvider | ||
*/ | ||
public function testInvalidEpsPaymentSource($data) | ||
{ | ||
$paymentSource = new PaymentSource( | ||
'eps', | ||
'Eps', | ||
[ | ||
new AmountEligibilityRule($data['amount'], '1'), | ||
new CountryEligibilityRule($data['buyerCountry'], ['AT']), | ||
new CurrencyEligibilityRule($data['currency'], ['EUR']), | ||
new ExcludedCountryEligibilityRule($data['merchantCountry'], ['RU', 'JP', 'BR']), | ||
], | ||
[ | ||
new PaymentSourceUseCase( | ||
'ECM', | ||
[ | ||
new IntentEligibilityRule($data['intent'], ['CAPTURE']), | ||
new PageTypeEligibilityRule($data['pageType'], ['checkout']) | ||
] | ||
) | ||
] | ||
); | ||
} | ||
|
||
public function invalidEpsDataProvider() | ||
{ | ||
return [ | ||
[ | ||
[ | ||
'amount' => '0.99', // Invalid amount | ||
'buyerCountry' => 'AT', | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'FR', // Invalid buyer country | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'US', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '9.90', | ||
'buyerCountry' => 'AT', | ||
'currency' => 'USD', // Invalid currency | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'US', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'AT', | ||
'currency' => 'EUR', | ||
'intent' => 'AUTHORIZE', // Invalid intent | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '15', | ||
'buyerCountry' => 'AT', | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'JP', // Invalid merchant country | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'AT', | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'product' // Invalid pageType | ||
], | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Amount; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\AmountEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\CountryEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\CurrencyEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\ExcludedCountryEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\IntentEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\EligibilityRule\PageTypeEligibilityRule; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\PaymentSource; | ||
use PrestaShop\Module\PrestashopCheckout\PaymentSource\PaymentSourceUseCase; | ||
|
||
class GiropayPaymentSourceTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider invalidGiropayDataProvider | ||
*/ | ||
public function testInvalidGiropayPaymentSource($data) | ||
{ | ||
$paymentSource = new PaymentSource( | ||
'giropay', | ||
'Giropay', | ||
[ | ||
new AmountEligibilityRule($data['amount'], '1'), | ||
new CountryEligibilityRule($data['buyerCountry'], ['DE']), | ||
new CurrencyEligibilityRule($data['currency'], ['EUR']), | ||
new ExcludedCountryEligibilityRule($data['merchantCountry'], ['RU', 'JP', 'BR']), | ||
], | ||
[ | ||
new PaymentSourceUseCase( | ||
'ECM', | ||
[ | ||
new IntentEligibilityRule($data['intent'], ['CAPTURE']), | ||
new PageTypeEligibilityRule($data['pageType'], ['checkout']) | ||
] | ||
) | ||
] | ||
); | ||
} | ||
|
||
public function invalidGiropayDataProvider() | ||
{ | ||
return [ | ||
[ | ||
[ | ||
'amount' => '0.99', // Invalid amount | ||
'buyerCountry' => 'DE', | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'FR', // Invalid buyer country | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'US', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '9.90', | ||
'buyerCountry' => 'DE', | ||
'currency' => 'USD', // Invalid currency | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'US', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'DE', | ||
'currency' => 'EUR', | ||
'intent' => 'AUTHORIZE', // Invalid intent | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '15', | ||
'buyerCountry' => 'DE', | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'JP', // Invalid merchant country | ||
'pageType' => 'checkout' | ||
], | ||
], | ||
[ | ||
[ | ||
'amount' => '39.99', | ||
'buyerCountry' => 'DE', | ||
'currency' => 'EUR', | ||
'intent' => 'CAPTURE', | ||
'merchantCountry' => 'FR', | ||
'pageType' => 'product' // Invalid pageType | ||
], | ||
] | ||
]; | ||
} | ||
} |
Oops, something went wrong.