1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hipanel\modules\finance\tests\_support\Page\price; |
4
|
|
|
|
5
|
|
|
class Create extends View |
6
|
|
|
{ |
7
|
|
|
public function createRandomPrices(string $objectName, string $templateName, string $priceType): void |
8
|
|
|
{ |
9
|
|
|
$this->loadPage(); |
10
|
|
|
$this->openModal(); |
11
|
|
|
$this->chooseObject($objectName); |
12
|
|
|
$this->chooseTemplate($templateName); |
13
|
|
|
$this->choosePriceType($priceType); |
14
|
|
|
$this->proceedToCreation(); |
15
|
|
|
$this->fillRandomPrices('price'); |
16
|
|
|
$this->saveForm(); |
17
|
|
|
$this->seeRandomPrices(); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function openModal(): void |
21
|
|
|
{ |
22
|
|
|
$I = $this->tester; |
23
|
|
|
|
24
|
|
|
$I->click('Create'); |
25
|
|
|
$I->waitForElement('#create-prices'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
View Code Duplication |
public function choosePriceType(string $priceType): void |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$I = $this->tester; |
31
|
|
|
|
32
|
|
|
$I->click('//div[contains(@class, "field-type")]/span'); |
33
|
|
|
$I->fillField('.select2-search__field', $priceType); |
34
|
|
|
$I->waitForElementNotVisible('.loading-results', 120); |
35
|
|
|
$I->click("//li[contains(text(), '{$priceType}')]"); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
View Code Duplication |
public function chooseObject(string $objectName): void |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
$I = $this->tester; |
41
|
|
|
|
42
|
|
|
$I->click('//div[contains(@class, "field-object_id")]/span'); |
43
|
|
|
$I->fillField('.select2-search__field', $objectName); |
44
|
|
|
$I->waitForElementNotVisible('.loading-results', 120); |
45
|
|
|
$I->click("//li[text()='{$objectName}']"); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
View Code Duplication |
public function chooseTemplate(string $templateName): void |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
$I = $this->tester; |
51
|
|
|
|
52
|
|
|
$I->fillField('.select2-search__field', $templateName); |
53
|
|
|
$I->waitForElementNotVisible('.loading-results', 120); |
54
|
|
|
$I->click("//li[contains(text(), '{$templateName}')]"); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function proceedToCreation(): void |
58
|
|
|
{ |
59
|
|
|
$I = $this->tester; |
60
|
|
|
|
61
|
|
|
$I->click('Proceed to creation'); |
62
|
|
|
$I->waitForText('Create suggested prices'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function saveForm(): void |
66
|
|
|
{ |
67
|
|
|
$I = $this->tester; |
68
|
|
|
|
69
|
|
|
$I->click('Save'); |
70
|
|
|
$I->closeNotification('Prices were successfully created'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.