|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace advancedhosters\hipanel\tests\acceptance\module\finance\manager; |
|
4
|
|
|
|
|
5
|
|
|
use Codeception\Example; |
|
6
|
|
|
use hipanel\helpers\Url; |
|
7
|
|
|
use hipanel\modules\finance\tests\_support\Page\price\Create as PriceCreatePage; |
|
8
|
|
|
use hipanel\modules\finance\tests\acceptance\manager\PriceCest as BasePriceCest; |
|
9
|
|
|
use hipanel\tests\_support\Step\Acceptance\Manager; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class PriceCest |
|
13
|
|
|
* |
|
14
|
|
|
* @author Dmytro Naumenko <[email protected]> |
|
15
|
|
|
*/ |
|
16
|
|
|
class PriceCest extends BasePriceCest |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
private $templateName; |
|
22
|
|
|
|
|
23
|
|
|
public function _before(Manager $I) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->ensureIHaveTestTemplate($I); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return array of types that should be included in template plan |
|
30
|
|
|
* |
|
31
|
|
|
* ```php |
|
32
|
|
|
* return [ |
|
33
|
|
|
* ['vCDN'], |
|
34
|
|
|
* ['pCDN'] |
|
35
|
|
|
* ]; |
|
36
|
|
|
* ``` |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function templatePriceTypesProvider(): array |
|
39
|
|
|
{ |
|
40
|
|
|
return [ |
|
41
|
|
|
['Model groups'], |
|
42
|
|
|
['Dedicated Server'], |
|
43
|
|
|
['vCDN'], |
|
44
|
|
|
['pCDN'] |
|
45
|
|
|
]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @dataProvider templatePriceTypesProvider |
|
50
|
|
|
* @param Manager $I |
|
51
|
|
|
* @param Example $example |
|
52
|
|
|
*/ |
|
53
|
|
|
public function ensureICanCreateTemplatePlan(Manager $I, Example $example): void |
|
54
|
|
|
{ |
|
55
|
|
|
$page = new PriceCreatePage($I, $this->id); |
|
56
|
|
|
$page->openModal(); |
|
57
|
|
|
$page->choosePriceType($example[0]); |
|
58
|
|
|
$page->proceedToCreation(); |
|
59
|
|
|
$page->fillRandomPrices('templateprice'); |
|
60
|
|
|
$page->saveForm(); |
|
61
|
|
|
$page->seeRandomPrices(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
private function ensureIHaveTestTemplate(Manager $I): void |
|
65
|
|
|
{ |
|
66
|
|
|
if (!$this->templateName) { |
|
67
|
|
|
$this->templateName = uniqid('TemplatePlan', true); |
|
68
|
|
|
$this->id = $this->createPlan($I, $this->templateName, 'Template'); |
|
69
|
|
|
$I->needPage(Url::to(['@plan/view', 'id' => $this->id])); |
|
70
|
|
|
$I->see('No prices found'); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
protected function suggestedPricesOptionsProvider(Manager $I): array |
|
75
|
|
|
{ |
|
76
|
|
|
return [ |
|
77
|
|
|
[ |
|
78
|
|
|
'type' => 'Server', |
|
79
|
|
|
'templateName' => $this->templateName, |
|
80
|
|
|
'priceTypes' => ['Main prices', 'Parts prices'], |
|
81
|
|
|
'object' => 'DS5000', |
|
82
|
|
|
], |
|
83
|
|
|
[ |
|
84
|
|
|
'type' => 'vCDN', |
|
85
|
|
|
'templateName' => $this->templateName, |
|
86
|
|
|
'priceTypes' => ['Main prices'], |
|
87
|
|
|
'object' => 'vCDN-soltest', |
|
88
|
|
|
], |
|
89
|
|
|
]; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|