Skip to content

Commit 4216184

Browse files
authored
Update the PBL validation to display errors (#331)
2 parents fb2a6fe + 827a0d8 commit 4216184

13 files changed

Lines changed: 47 additions & 228 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ jobs:
9898
run: vendor/bin/phpunit --testsuite api
9999

100100
- name: Run tests (E2E)
101-
run: vendor/bin/phpunit --testsuite e2e --exclude-group requires-fixes
101+
run: |
102+
find tests/E2E/ -type f -name '*Test.php' -print0 |
103+
while IFS= read -r -d '' file; do
104+
vendor/bin/phpunit --exclude-group requires-fixes "$file" || \
105+
vendor/bin/phpunit --exclude-group requires-fixes "$file"
106+
done
102107
103108
- name: Run Tpay contract tests
104109
if: "${{ inputs.type == 'daily' }}"

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"symfony/panther": "^2.1",
6565
"symfony/runtime": "6.4.* || ^7.0",
6666
"symfony/web-profiler-bundle": "6.4.* || ^7.0",
67-
"theofidry/alice-data-fixtures": "^1.6",
67+
"theofidry/alice-data-fixtures": "1.7.2",
6868
"winzou/state-machine-bundle": "^0.6.2"
6969
},
7070
"conflict": {

src/Form/Extension/CompleteTypeExtension.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use CommerceWeavers\SyliusTpayPlugin\Form\Type\TpayPaymentDetailsType;
88
use CommerceWeavers\SyliusTpayPlugin\Model\OrderLastNewPaymentAwareInterface;
9-
use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Validator\Constraint\RequiresTpayChannelId;
109
use Sylius\Bundle\CoreBundle\Form\Type\Checkout\CompleteType;
1110
use Sylius\Component\Core\Model\OrderInterface;
1211
use Symfony\Component\Form\AbstractTypeExtension;
@@ -47,7 +46,6 @@ private function addType(FormBuilderInterface $builder, array $validationGroups)
4746
'property_path' => 'last_cart_payment.details[tpay]',
4847
'constraints' => [
4948
new Valid(groups: ['sylius_checkout_complete']),
50-
new RequiresTpayChannelId(groups: ['sylius_checkout_complete']),
5149
],
5250
'validation_groups' => static function (FormInterface $form) use ($validationGroups): array {
5351
$order = $form->getRoot()->getData();

src/Form/Type/TpayPaymentDetailsType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
8383
HiddenType::class,
8484
[
8585
'constraints' => [
86-
new NotBlank(groups: ['tpay_pbl']),
86+
new NotBlank(message: 'commerce_weavers_sylius_tpay.shop.pay.tpay_channel.required', groups: ['tpay_pbl']),
8787
new ValidTpayChannel(groups: ['tpay_pbl']),
8888
],
8989
'error_bubbling' => false,

src/PayByLinkPayment/Validator/Constraint/RequiresTpayChannelId.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/PayByLinkPayment/Validator/Constraint/RequiresTpayChannelIdValidator.php

Lines changed: 0 additions & 50 deletions
This file was deleted.

templates/shop/order/pay/pay_by_link.html.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{% set form = get_hookable_context().parent_form %}
22

33
<div data-payment-details="tpay_pbl">
4+
{{ form_errors(form.tpay.tpay_channel_id) }}
5+
46
{{ component('cw_tpay_shop:pay_by_link:channel_picker', { 'order': get_hookable_context().resource }) }}
57

68
{{ form_row(form.tpay.tpay_channel_id, { attr: { 'data-tpay-channel-id': '' } }) }}

tests/Api/Responses/shop/paying_for_orders_by_blik/test_paying_using_an_expired_blik_alias.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/Api/Shop/PayingForOrdersByBlikTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ public function test_paying_using_an_expired_blik_alias(): void
172172
);
173173

174174
$response = $this->client->getResponse();
175+
$content = json_decode($response->getContent(), true);
175176

176-
$this->assertResponse($response, 'shop/paying_for_orders_by_blik/test_paying_using_an_expired_blik_alias', Response::HTTP_BAD_REQUEST);
177+
$this->assertSame('An error occurred', $content['hydra:title']);
178+
$this->assertSame('The Blik Alias expired. Please register a new one or use a Blik token.', $content['hydra:description']);
177179
}
178180

179181
public function test_paying_using_not_registered_blik_alias(): void
@@ -196,8 +198,10 @@ public function test_paying_using_not_registered_blik_alias(): void
196198
);
197199

198200
$response = $this->client->getResponse();
201+
$content = json_decode($response->getContent(), true);
199202

200-
$this->assertResponse($response, 'shop/paying_for_orders_by_blik/test_paying_using_not_registered_blik_alias', Response::HTTP_BAD_REQUEST);
203+
$this->assertSame('An error occurred', $content['hydra:title']);
204+
$this->assertSame('The Blik Alias is not registered yet. Please try again later or use a Blik token.', $content['hydra:description']);
201205
}
202206

203207
public function test_paying_using_a_valid_blik_alias_but_registered_in_more_than_one_bank_app(): void

tests/E2E/E2ETestCase.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
88
use Doctrine\ORM\EntityManager;
99
use Doctrine\ORM\EntityManagerInterface;
10-
use Facebook\WebDriver\Firefox\FirefoxOptions;
10+
use Facebook\WebDriver\Chrome\ChromeOptions;
1111
use Facebook\WebDriver\WebDriverDimension;
1212
use Fidry\AliceDataFixtures\LoaderInterface;
1313
use Symfony\Component\Panther\Client;
@@ -24,11 +24,10 @@ abstract class E2ETestCase extends PantherTestCase
2424

2525
protected function setUp(): void
2626
{
27-
$options = new FirefoxOptions();
28-
$options->setPreference('intl.accept_languages', 'en-US');
27+
$options = new ChromeOptions();
2928

3029
$this->client = static::createPantherClient([
31-
'browser' => self::FIREFOX, [], $options,
30+
'browser' => self::CHROME, [], $options,
3231
]);
3332
$this->client->manage()->window()->setSize(
3433
new WebDriverDimension(1500, 4000),
@@ -37,6 +36,12 @@ protected function setUp(): void
3736
parent::setUp();
3837
}
3938

39+
protected function tearDown(): void
40+
{
41+
parent::tearDown();
42+
$this->client->restart();
43+
}
44+
4045
/**
4146
* @before
4247
*/

0 commit comments

Comments
 (0)