Skip to content

Commit

Permalink
Add E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
arti0090 committed Oct 18, 2024
1 parent 5f4e4a5 commit 4d37b8d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
10 changes: 2 additions & 8 deletions config/config/sylius_fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,11 @@
'enabled' => true,
],
'visa_mobile' => [
'code' => 'visa_mobile',
'code' => 'tpay_visa_mobile',
'name' => 'Visa mobile (Tpay)',
'gatewayFactory' => 'tpay',
'gatewayName' => 'tpay',
'gatewayConfig' => [
'client_id' => '%env(string:TPAY_CLIENT_ID)%',
'client_secret' => '%env(string:TPAY_CLIENT_SECRET)%',
'type' => PaymentType::VISA_MOBILE,
'notification_security_code' => '%env(string:TPAY_NOTIFICATION_SECURITY_CODE)%',
'production_mode' => false,
],
'gatewayConfig' => $tpayConfig + ['type' => PaymentType::VISA_MOBILE],
'channels' => [
'FASHION_WEB',
],
Expand Down
3 changes: 3 additions & 0 deletions src/Form/DataTransformer/VisaMobilePhoneDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace CommerceWeavers\SyliusTpayPlugin\Form\DataTransformer;

use Symfony\Component\Form\DataTransformerInterface;
use Webmozart\Assert\Assert;

final class VisaMobilePhoneDataTransformer implements DataTransformerInterface
{
Expand All @@ -16,6 +17,8 @@ public function transform($value): ?string
return '';
}

Assert::string($value);

if (strlen($value) > 9 && str_starts_with($value, self::PREFIX)) {
return substr($value, 2);
}
Expand Down
9 changes: 9 additions & 0 deletions tests/E2E/Checkout/TpayPaymentCheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ public function test_it_completes_the_checkout_using_blik(): void

$this->assertPageTitleContains('Waiting for payment');
}

public function test_it_completes_the_checkout_using_visa_mobile(): void
{
$this->processWithPaymentMethod('tpay_visa_mobile');
$this->fillVisaMobile(self::FORM_ID, '123123123');
$this->placeOrder();

$this->assertPageTitleContains('Waiting for payment');
}
}
5 changes: 5 additions & 0 deletions tests/E2E/Helper/Order/TpayTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public function fillBlikToken(string $formId, string $blikToken): void
{
$this->client->findElement(WebDriverBy::id(sprintf('%s_tpay_blik_token', $formId)))->sendKeys($blikToken);
}

public function fillVisaMobile(string $formId, string $mobilePhone): void
{
$this->client->findElement(WebDriverBy::id(sprintf('%s_tpay_visa_mobile_phone_number', $formId)))->sendKeys($mobilePhone);
}
}
21 changes: 21 additions & 0 deletions tests/E2E/Resources/fixtures/common/payment_method.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ Sylius\Component\Core\Model\PaymentMethod:
translations:
- '@tpay_pbl_payment_method_translation'
channels: [ '@channel_web' ]
tpay_visa_mobile:
code: 'tpay_visa_mobile'
enabled: true
gatewayConfig: '@gateway_tpay_visa_mobile'
translations:
- '@tpay_visa_mobile_payment_method_translation'
channels: [ '@channel_web' ]

Sylius\Bundle\PayumBundle\Model\GatewayConfig:
gateway_tpay:
Expand Down Expand Up @@ -81,6 +88,15 @@ Sylius\Bundle\PayumBundle\Model\GatewayConfig:
type: 'pay_by_link'
production_mode: false
encrypted: true
gateway_tpay_visa_mobile:
gatewayName: 'tpay'
factoryName: 'tpay'
config:
client_id: 'encrypted_<getenv("TPAY_CLIENT_ID")>'
client_secret: 'encrypted_<getenv("TPAY_CLIENT_SECRET")>'
type: 'visa_mobile'
production_mode: false
encrypted: true

Sylius\Component\Payment\Model\PaymentMethodTranslation:
tpay_payment_method_translation:
Expand Down Expand Up @@ -108,3 +124,8 @@ Sylius\Component\Payment\Model\PaymentMethodTranslation:
locale: 'en_US'
description: '<paragraph(2)>'
translatable: '@tpay_pbl'
tpay_visa_mobile_payment_method_translation:
name: 'Visa mobile (Tpay)'
locale: 'en_US'
description: '<paragraph(2)>'
translatable: '@tpay_visa_mobile'

0 comments on commit 4d37b8d

Please sign in to comment.