[Behat] Adjust scenarios for paypal express checkout and phpunit tests

This commit is contained in:
Mateusz Zalewski 2017-01-10 14:44:39 +01:00
parent 93d90be5fd
commit 03d9c25685
No known key found for this signature in database
GPG key ID: BE101BD4D91463A4
5 changed files with 31 additions and 12 deletions

View file

@ -25,13 +25,6 @@ monolog:
payum:
gateways:
paypal_express_checkout:
factory: paypal_express_checkout
payum.http_client: "@sylius.payum.http_client"
username: TEST
password: TEST
signature: TEST
sandbox: true
credit_card:
factory: stripe_checkout
secret_key: EDITME

View file

@ -7,9 +7,10 @@ Feature: Paying with paypal during checkout
Background:
Given the store operates on a single channel in "United States"
And there is a user "john@example.com" identified by "password123"
And the store has a payment method "PayPal Express Checkout" with a code "PAYPAL" and gateway factory "Paypal Express Checkout"
And gateway of this payment method is configured with username "TEST", password "TEST" and "TEST" signature
And the store has a product "PHP T-Shirt" priced at "$19.99"
And the store ships everywhere for free
And the store allows paying "PayPal Express Checkout"
And I am logged in as "john@example.com"
@ui

View file

@ -115,6 +115,25 @@ final class PaymentContext implements Context
$this->createPaymentMethod($paymentMethodName, $paymentMethodCode, $gatewayFactory);
}
/**
* @Given /^gateway of (this payment method) is configured with username "([^"]+)", password "([^"]+)" and "([^"]+)" signature$/
*/
public function gatewayOfThisPaymentMethodIsConfiguredWithUsernamePasswordAndSignature(
PaymentMethodInterface $paymentMethod,
$username,
$password,
$signature
) {
$paymentMethod->getGatewayConfig()->setConfig([
'username' => $username,
'password' => $password,
'signature' => $signature,
'sandbox' => true,
]);
$this->objectManager->flush();
}
/**
* @Given /^(this payment method) is named "([^"]+)" in the "([^"]+)" locale$/
*/
@ -179,7 +198,7 @@ final class PaymentContext implements Context
) {
/** @var PaymentMethodInterface $paymentMethod */
$paymentMethod = $this->paymentMethodFactory->createWithGateway(array_search($gatewayFactory, $this->gatewayFactories));
$paymentMethod->getGatewayConfig()->setGatewayName($gatewayFactory);
$paymentMethod->getGatewayConfig()->setGatewayName(array_search($gatewayFactory, $this->gatewayFactories));
$paymentMethod->setName(ucfirst($name));
$paymentMethod->setCode($code);
$paymentMethod->setPosition($position);

View file

@ -126,7 +126,7 @@ final class PayumController
}
$captureToken = $this->getTokenFactory()->createCaptureToken(
$payment->getMethod()->getGateway(),
$payment->getMethod()->getGatewayConfig()->getGatewayName(),
$payment,
isset($options['route']) ? $options['route'] : null,
isset($options['parameters']) ? $options['parameters'] : []

View file

@ -100,16 +100,22 @@ Sylius\Component\Core\Model\PaymentMethod:
cash_on_delivery:
code: cod
enabled: true
gateway: 'offline'
gatewayConfig: '@offline'
currentLocale: en_US
currentTranslation: "@cash_on_delivery_translation1"
channels: ['@channel']
pay_by_check:
code: pbc
enabled: true
gateway: 'offline'
gatewayConfig: '@offline'
channels: ['@channel']
Sylius\Bundle\PayumBundle\Model\GatewayConfig:
offline:
gatewayName: 'Offline'
factoryName: 'offline'
config: []
Sylius\Component\Payment\Model\PaymentMethodTranslation:
cash_on_delivery_translation1:
name: 'Cach on delivery'