|
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
|
|
|
namespace Sylius\Behat\Page\Shop\Account\Order; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Mink\Session; |
|
15
|
|
|
use Sylius\Behat\Page\SymfonyPage; |
|
16
|
|
|
use Sylius\Behat\Service\Accessor\TableAccessorInterface; |
|
17
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Grzegorz Sadowski <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class IndexPage extends SymfonyPage implements IndexPageInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var TableAccessorInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
private $tableAccessor; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param Session $session |
|
31
|
|
|
* @param array $parameters |
|
32
|
|
|
* @param RouterInterface $router |
|
33
|
|
|
* @param TableAccessorInterface $tableAccessor |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
Session $session, |
|
37
|
|
|
array $parameters, |
|
38
|
|
|
RouterInterface $router, |
|
39
|
|
|
TableAccessorInterface $tableAccessor |
|
40
|
|
|
) { |
|
41
|
|
|
parent::__construct($session, $parameters, $router); |
|
42
|
|
|
|
|
43
|
|
|
$this->tableAccessor = $tableAccessor; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getRouteName() |
|
50
|
|
|
{ |
|
51
|
|
|
return 'sylius_shop_account_order_index'; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* {@inheritdoc} |
|
56
|
|
|
*/ |
|
57
|
|
|
public function countOrders() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->tableAccessor->countTableBodyRows($this->getElement('customer_orders')); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* {@inheritdoc} |
|
64
|
|
|
*/ |
|
65
|
|
|
public function isOrderWithNumberInTheList($number) |
|
66
|
|
|
{ |
|
67
|
|
|
try { |
|
68
|
|
|
$rows = $this->tableAccessor->getRowsWithFields( |
|
69
|
|
|
$this->getElement('customer_orders'), |
|
70
|
|
|
['number' => $number] |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
return 1 === count($rows); |
|
74
|
|
|
|
|
75
|
|
|
} catch (\InvalidArgumentException $exception) { |
|
76
|
|
|
return false; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* {@inheritdoc} |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function getDefinedElements() |
|
84
|
|
|
{ |
|
85
|
|
|
return array_merge(parent::getDefinedElements(), [ |
|
86
|
|
|
'customer_orders' => '#sylius-customer-orders', |
|
87
|
|
|
]); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|