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\Context\Ui\Shop\Checkout; |
15
|
|
|
|
16
|
|
|
use Behat\Behat\Context\Context; |
17
|
|
|
use Sylius\Behat\Page\Shop\Order\ShowPageInterface; |
18
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
19
|
|
|
use Webmozart\Assert\Assert; |
20
|
|
|
|
21
|
|
|
final class CheckoutOrderDetailsContext implements Context |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var ShowPageInterface |
25
|
|
|
*/ |
26
|
|
|
private $orderDetails; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param ShowPageInterface $orderDetails |
30
|
|
|
*/ |
31
|
|
|
public function __construct(ShowPageInterface $orderDetails) |
32
|
|
|
{ |
33
|
|
|
$this->orderDetails = $orderDetails; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @When /^I want to browse order details for (this order)$/ |
38
|
|
|
*/ |
39
|
|
|
public function iWantToBrowseOrderDetailsForThisOrder(OrderInterface $order) |
40
|
|
|
{ |
41
|
|
|
$this->orderDetails->open(['tokenValue' => $order->getTokenValue()]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @When I try to pay with :paymentMethodName payment method |
46
|
|
|
*/ |
47
|
|
|
public function iChangePaymentMethodTo($paymentMethodName) |
48
|
|
|
{ |
49
|
|
|
$this->orderDetails->choosePaymentMethod($paymentMethodName); |
50
|
|
|
$this->orderDetails->pay(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Then I should be able to pay (again) |
55
|
|
|
*/ |
56
|
|
|
public function iShouldBeAbleToPay() |
57
|
|
|
{ |
58
|
|
|
Assert::true($this->orderDetails->hasPayAction()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @Then I should not be able to pay (again) |
63
|
|
|
*/ |
64
|
|
|
public function iShouldNotBeAbleToPay() |
65
|
|
|
{ |
66
|
|
|
Assert::false($this->orderDetails->hasPayAction()); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Then I should see :quantity as number of items |
71
|
|
|
*/ |
72
|
|
|
public function iShouldSeeAsNumberOfItems(int $quantity): void |
73
|
|
|
{ |
74
|
|
|
Assert::same($this->orderDetails->getNumberOfItems(), $quantity); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|