1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Finance module for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
6
|
|
|
* @package hipanel-module-finance |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\finance\tests\_support\Page\plan; |
12
|
|
|
|
13
|
|
|
use hipanel\helpers\Url; |
14
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Select2; |
15
|
|
|
|
16
|
|
|
class Create extends Plan |
17
|
|
|
{ |
18
|
|
|
protected function loadPage() |
19
|
|
|
{ |
20
|
|
|
$I = $this->tester; |
21
|
|
|
|
22
|
|
|
$I->needPage(Url::to('@plan/create')); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
protected function savePlan() |
26
|
|
|
{ |
27
|
|
|
$I = $this->tester; |
28
|
|
|
|
29
|
|
|
$I->click('Save'); |
30
|
|
|
$I->closeNotification('Plan was successfully created'); |
31
|
|
|
|
32
|
|
|
$this->id = $I->grabFromCurrentUrl('/id=(\d+)/'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function createPlan(): int |
36
|
|
|
{ |
37
|
|
|
$this->loadPage(); |
38
|
|
|
$this->fillName(); |
39
|
|
|
$this->chooseType(); |
40
|
|
|
$this->setGrouping(); |
41
|
|
|
$this->findClient(); |
42
|
|
|
$this->chooseCurrency(); |
43
|
|
|
$this->fillNote(); |
44
|
|
|
$this->savePlan(); |
45
|
|
|
|
46
|
|
|
return $this->id; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
private function fillName() |
50
|
|
|
{ |
51
|
|
|
$I = $this->tester; |
52
|
|
|
|
53
|
|
|
$I->fillField(['name' => 'Plan[name]'], $this->name); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
private function chooseType() |
57
|
|
|
{ |
58
|
|
|
$I = $this->tester; |
59
|
|
|
|
60
|
|
|
$I->click(['name' => 'Plan[type]']); |
61
|
|
|
$I->click("//select/option[.='{$this->type}']"); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
protected function setGrouping() |
65
|
|
|
{ |
66
|
|
|
$I = $this->tester; |
67
|
|
|
|
68
|
|
|
$I->uncheckOption("//input[@name='Plan[is_grouping]'][@type='checkbox']"); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
private function findClient() |
72
|
|
|
{ |
73
|
|
|
(new Select2($this->tester, '#plan-client')) |
74
|
|
|
->setValue($this->client); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
private function chooseCurrency() |
78
|
|
|
{ |
79
|
|
|
(new Select2($this->tester, '#plan-currency')) |
80
|
|
|
->setValueLike($this->currency); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
private function fillNote() |
84
|
|
|
{ |
85
|
|
|
$I = $this->tester; |
86
|
|
|
|
87
|
|
|
$I->fillField(['name' => 'Plan[note]'], $this->note); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function seeFields() |
91
|
|
|
{ |
92
|
|
|
$this->loadPage(); |
93
|
|
|
$this->seeLabels(); |
94
|
|
|
$this->seeTypeDropdownList(); |
95
|
|
|
$this->seeCurrencyDropdownList(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
private function seeLabels() |
99
|
|
|
{ |
100
|
|
|
$I = $this->tester; |
101
|
|
|
|
102
|
|
|
$list = ['Name', 'Type', 'Seller', 'Currency', 'Note']; |
103
|
|
|
foreach ($list as $label) { |
104
|
|
|
$I->see($label, "//label[@class='control-label']"); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
private function seeTypeDropdownList() |
109
|
|
|
{ |
110
|
|
|
$I = $this->tester; |
111
|
|
|
|
112
|
|
|
$list = [ |
113
|
|
|
'server' => 'Server', |
114
|
|
|
'vcdn' => 'vCDN', |
115
|
|
|
'pcdn' => 'pCDN', |
116
|
|
|
'ip' => 'IP', |
117
|
|
|
'account' => 'Account', |
118
|
|
|
'domain' => 'Domain', |
119
|
|
|
'client' => 'Client', |
120
|
|
|
'template' => 'Template', |
121
|
|
|
]; |
122
|
|
|
$I->click(['name' => 'Plan[type]']); |
123
|
|
|
foreach ($list as $key => $text) { |
124
|
|
|
$I->see($text, "//select/option[@value='{$key}']"); |
125
|
|
|
} |
126
|
|
|
$I->clickWithLeftButton('h1'); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
private function seeCurrencyDropdownList() |
130
|
|
|
{ |
131
|
|
|
$I = $this->tester; |
132
|
|
|
|
133
|
|
|
$I->click("//select[@name='Plan[currency]']/../span"); |
134
|
|
|
$list = [ |
135
|
|
|
'usd' => 'USD', |
136
|
|
|
'eur' => 'EUR', |
137
|
|
|
'uah' => 'UAH', |
138
|
|
|
'rub' => 'RUB', |
139
|
|
|
'pln' => 'PLN', |
140
|
|
|
'btc' => 'BTC', |
141
|
|
|
]; |
142
|
|
|
foreach ($list as $key => $text) { |
143
|
|
|
$I->see($text, "//select/option[@value='{$key}']"); |
144
|
|
|
} |
145
|
|
|
$I->clickWithLeftButton('h1'); |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|