|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Sylius\Behat\Page\Shop\Order; |
|
15
|
|
|
|
|
16
|
|
|
use Behat\Mink\Element\NodeElement; |
|
17
|
|
|
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage; |
|
18
|
|
|
|
|
19
|
|
|
class ShowPage extends SymfonyPage implements ShowPageInterface |
|
20
|
|
|
{ |
|
21
|
|
|
public function hasPayAction(): bool |
|
22
|
|
|
{ |
|
23
|
|
|
return $this->hasElement('pay_link'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function pay(): void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->getElement('pay_link')->click(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getNotifications(): array |
|
32
|
|
|
{ |
|
33
|
|
|
/** @var NodeElement[] $notificationElements */ |
|
34
|
|
|
$notificationElements = $this->getDocument()->findAll('css', '[data-test-flash-messages]'); |
|
35
|
|
|
$notifications = []; |
|
36
|
|
|
|
|
37
|
|
|
foreach ($notificationElements as $notificationElement) { |
|
38
|
|
|
$notifications[] = $notificationElement->getText(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return $notifications; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function choosePaymentMethod(string $paymentMethodName): void |
|
45
|
|
|
{ |
|
46
|
|
|
$paymentMethodElement = $this->getElement('payment_method', ['%name%' => $paymentMethodName]); |
|
47
|
|
|
$paymentMethodElement->selectOption($paymentMethodElement->getAttribute('value')); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getRouteName(): string |
|
51
|
|
|
{ |
|
52
|
|
|
return 'sylius_shop_order_show'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getAmountOfItems(): int |
|
56
|
|
|
{ |
|
57
|
|
|
$paymentItems = $this->getDocument()->findAll('css', '[data-test-payment-item]'); |
|
58
|
|
|
|
|
59
|
|
|
return count($paymentItems); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function getDefinedElements(): array |
|
63
|
|
|
{ |
|
64
|
|
|
return array_merge(parent::getDefinedElements(), [ |
|
65
|
|
|
'pay_link' => '[data-test-pay-link]', |
|
66
|
|
|
'payment_method' => '[data-test-payment-item]:contains("%name%") [data-test-payment-method-select]', |
|
67
|
|
|
]); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|