1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\SalesBundle\Tests\Selenium\Pages; |
4
|
|
|
|
5
|
|
|
use Oro\Bundle\TestFrameworkBundle\Pages\AbstractPageEntity; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class SalesFunnel |
9
|
|
|
* |
10
|
|
|
* @package OroCRM\Bundle\SalesBundle\Tests\Selenium\Pages |
11
|
|
|
*/ |
12
|
|
|
class SalesFunnel extends AbstractPageEntity |
13
|
|
|
{ |
14
|
|
|
/** @var \PHPUnit_Extensions_Selenium2TestCase_Element */ |
15
|
|
|
protected $startDate; |
16
|
|
|
/** @var \PHPUnit_Extensions_Selenium2TestCase_Element */ |
17
|
|
|
protected $lead; |
18
|
|
|
/** @var \PHPUnit_Extensions_Selenium2TestCase_Element */ |
19
|
|
|
protected $opportunity; |
20
|
|
|
|
21
|
|
|
protected $owner = "//div[starts-with(@id,'s2id_oro_workflow_transition_sales_funnel_owner')]/a"; |
22
|
|
|
|
23
|
|
View Code Duplication |
public function setStartDate($date) |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
$this->startDate = $this->test->byXpath("//*[@data-ftid='oro_workflow_transition_sales_funnel_start_date']/..". |
26
|
|
|
"/following-sibling::input[contains(@class,'datepicker-input')]"); |
27
|
|
|
$this->startDate->clear(); |
28
|
|
|
$this->startDate->value($date); |
29
|
|
|
|
30
|
|
|
return $this; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
View Code Duplication |
public function setLead($lead) |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
$this->lead = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_workflow_transition_lead')]/a"); |
36
|
|
|
$this->lead->click(); |
37
|
|
|
$this->waitForAjax(); |
38
|
|
|
$this->test->byXpath("//div[@id='select2-drop']/div/input")->value($lead); |
39
|
|
|
$this->waitForAjax(); |
40
|
|
|
$this->assertElementPresent( |
41
|
|
|
"//div[@id='select2-drop']//div[contains(., '{$lead}')]", |
42
|
|
|
"Lead autocomplete doesn't return search value" |
43
|
|
|
); |
44
|
|
|
$this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$lead}')]")->click(); |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function selectEntity($type, $entity) |
50
|
|
|
{ |
51
|
|
|
$this->opportunity = $this->test->byXpath( |
52
|
|
|
"(//button[contains(@class, 'entity-select-btn')])[last()]" |
53
|
|
|
); |
54
|
|
|
$this->opportunity->click(); |
55
|
|
|
$this->waitPageToLoad(); |
56
|
|
|
$this->waitForAjax(); |
57
|
|
|
$this->test->byXpath( |
58
|
|
|
"//div[@class='filter-container']//*[contains(@class,'filter-criteria-selector')]" |
59
|
|
|
. "[contains(., '{$type} name')]" |
60
|
|
|
)->click(); |
61
|
|
|
$filter = $this->test->byXpath( |
62
|
|
|
"//div[contains(@class, 'filter-item oro-drop open-filter' )]//input[@name='value']" |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$filter->clear(); |
66
|
|
|
$filter->value($entity); |
67
|
|
|
$this->test->byXPath( |
68
|
|
|
"//div[contains(@class, 'filter-item oro-drop open-filter' )]//button[contains(., 'Update')]" |
69
|
|
|
)->click(); |
70
|
|
|
$this->waitForAjax(); |
71
|
|
|
$this->test->byXpath( |
72
|
|
|
"//table[@class='grid table-hover table table-bordered table-condensed']//td[contains(., '{$entity}')]" |
73
|
|
|
)->click(); |
74
|
|
|
sleep(1); |
75
|
|
|
$this->waitPageToLoad(); |
76
|
|
|
$this->waitForAjax(); |
77
|
|
|
|
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param $channel |
83
|
|
|
* @return SalesFunnel |
84
|
|
|
*/ |
85
|
|
|
public function setChannel($channel) |
86
|
|
|
{ |
87
|
|
|
$element = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_workflow_transition_dataChannel')]/a"); |
88
|
|
|
$element->click(); |
89
|
|
|
$this->waitForAjax(); |
90
|
|
|
if ($this->isElementPresent("//div[@id='select2-drop']/div/input")) { |
91
|
|
|
$this->test->byXpath("//div[@id='select2-drop']/div/input")->value($channel); |
92
|
|
|
$this->waitForAjax(); |
93
|
|
|
$this->assertElementPresent( |
94
|
|
|
"//div[@id='select2-drop']//div[contains(., '{$channel}')]", |
95
|
|
|
"Channel autocomplete doesn't return search value" |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
$this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$channel}')]")->click(); |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function submit() |
104
|
|
|
{ |
105
|
|
|
$this->test->byXpath("//button[@id='save-and-transit']")->click(); |
106
|
|
|
$this->waitPageToLoad(); |
107
|
|
|
$this->waitForAjax(); |
108
|
|
|
|
109
|
|
|
return new Workflow($this->test); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function edit() |
113
|
|
|
{ |
114
|
|
|
$this->test->byXpath( |
115
|
|
|
"//div[@class='pull-left btn-group icons-holder']/a[@title = 'Edit sales process']" |
116
|
|
|
)->click(); |
117
|
|
|
$this->waitPageToLoad(); |
118
|
|
|
$this->waitForAjax(); |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function delete() |
124
|
|
|
{ |
125
|
|
|
$this->test->byXpath("//div[@class='pull-left btn-group icons-holder']/a[contains(., 'Delete')]")->click(); |
126
|
|
|
$this->test->byXpath("//div[div[contains(., 'Delete Confirmation')]]//a[text()='Yes, Delete']")->click(); |
127
|
|
|
$this->waitPageToLoad(); |
128
|
|
|
$this->waitForAjax(); |
129
|
|
|
|
130
|
|
|
return new SalesFunnels($this->test, false); |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
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.