|
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\Admin\Shipment; |
|
15
|
|
|
|
|
16
|
|
|
use Behat\Mink\Element\NodeElement; |
|
17
|
|
|
use Sylius\Behat\Page\Admin\Crud\IndexPage as BaseIndexPage; |
|
18
|
|
|
|
|
19
|
|
|
class IndexPage extends BaseIndexPage implements IndexPageInterface |
|
20
|
|
|
{ |
|
21
|
|
|
public function chooseStateToFilter(string $shipmentState): void |
|
22
|
|
|
{ |
|
23
|
|
|
$this->getElement('filter_state')->selectOption($shipmentState); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function shipShipmentOfOrderWithNumber(string $orderNumber): void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->getField($orderNumber, 'actions')->pressButton('Ship'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getShipmentStatusByOrderNumber(string $orderNumber): string |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->getField($orderNumber, 'state')->getText(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
private function getField(string $orderNumber, string $fieldName): NodeElement |
|
37
|
|
|
{ |
|
38
|
|
|
$tableAccessor = $this->getTableAccessor(); |
|
39
|
|
|
$table = $this->getElement('table'); |
|
40
|
|
|
|
|
41
|
|
|
$row = $tableAccessor->getRowWithFields($table, ['number' => $orderNumber]); |
|
42
|
|
|
|
|
43
|
|
|
return $field = $tableAccessor->getFieldFromRow($table, $row, $fieldName); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function showOrderPageForNthShipment(int $shipmentNumber): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->getActionsForRow($shipmentNumber)->clickLink('Show order details'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function getDefinedElements(): array |
|
52
|
|
|
{ |
|
53
|
|
|
return array_merge(parent::getDefinedElements(), [ |
|
54
|
|
|
'filter_state' => '#criteria_state', |
|
55
|
|
|
]); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function getActionsForRow(int $shipmentNumber): NodeElement |
|
59
|
|
|
{ |
|
60
|
|
|
$tableAccessor = $this->getTableAccessor(); |
|
61
|
|
|
$table = $this->getElement('table'); |
|
62
|
|
|
|
|
63
|
|
|
$row = $tableAccessor->getRowsWithFields($table, [])[$shipmentNumber]; |
|
64
|
|
|
|
|
65
|
|
|
return $field = $tableAccessor->getFieldFromRow($table, $row, 'actions'); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.