Code Duplication    Length = 15-17 lines in 5 locations

src/Oro/Bundle/SalesBundle/Tests/Selenium/Pages/B2BCustomer.php 3 locations

@@ 27-41 (lines=15) @@
24
        return $this->test->byXpath("//*[@data-ftid='oro_sales_b2bcustomer_form_name']")->value();
25
    }
26
27
    public function setOwner($owner)
28
    {
29
        $element = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_sales_b2bcustomer_form_owner')]/a");
30
        $element->click();
31
        $this->waitForAjax();
32
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($owner);
33
        $this->waitForAjax();
34
        $this->assertElementPresent(
35
            "//div[@id='select2-drop']//div[contains(., '{$owner}')]",
36
            "Owner autocomplete doesn't return search value"
37
        );
38
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$owner}')]")->click();
39
40
        return $this;
41
    }
42
43
    public function getOwner()
44
    {
@@ 48-62 (lines=15) @@
45
        return;
46
    }
47
48
    public function setAccount($account)
49
    {
50
        $element = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_sales_b2bcustomer_form_account')]/a");
51
        $element->click();
52
        $this->waitForAjax();
53
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($account);
54
        $this->waitForAjax();
55
        $this->assertElementPresent(
56
            "//div[@id='select2-drop']//div[contains(., '{$account}')]",
57
            "Owner autocomplete doesn't return search value"
58
        );
59
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$account}')]")->click();
60
61
        return $this;
62
    }
63
64
    public function setChannel($channel)
65
    {
@@ 64-80 (lines=17) @@
61
        return $this;
62
    }
63
64
    public function setChannel($channel)
65
    {
66
        $element = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_sales_b2bcustomer_form_dataChannel')]/a");
67
        $element->click();
68
        $this->waitForAjax();
69
        if ($this->isElementPresent("//div[@id='select2-drop']/div/input")) {
70
            $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($channel);
71
            $this->waitForAjax();
72
            $this->assertElementPresent(
73
                "//div[@id='select2-drop']//div[contains(., '{$channel}')]",
74
                "Channel autocomplete doesn't return search value"
75
            );
76
        }
77
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$channel}')]")->click();
78
79
        return $this;
80
    }
81
82
    public function edit()
83
    {

src/Oro/Bundle/SalesBundle/Tests/Selenium/Pages/Lead.php 1 location

@@ 481-497 (lines=17) @@
478
        return new Contacts($this->test, false);
479
    }
480
481
    public function setChannel($channel)
482
    {
483
        $element = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_sales_lead_form_dataChannel')]/a");
484
        $element->click();
485
        $this->waitForAjax();
486
        if ($this->isElementPresent("//div[@id='select2-drop']/div/input")) {
487
            $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($channel);
488
            $this->waitForAjax();
489
            $this->assertElementPresent(
490
                "//div[@id='select2-drop']//div[contains(., '{$channel}')]",
491
                "Channel autocomplete doesn't return search value"
492
            );
493
        }
494
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$channel}')]")->click();
495
496
        return $this;
497
    }
498
}
499

src/Oro/Bundle/SalesBundle/Tests/Selenium/Pages/Opportunity.php 1 location

@@ 93-109 (lines=17) @@
90
        )->text();
91
    }
92
93
    public function setChannel($channel)
94
    {
95
        $element = $this->test->byXpath("//div[starts-with(@id,'s2id_oro_sales_opportunity_form_dataChannel')]/a");
96
        $element->click();
97
        $this->waitForAjax();
98
        if ($this->isElementPresent("//div[@id='select2-drop']/div/input")) {
99
            $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($channel);
100
            $this->waitForAjax();
101
            $this->assertElementPresent(
102
                "//div[@id='select2-drop']//div[contains(., '{$channel}')]",
103
                "Channel autocomplete doesn't return search value"
104
            );
105
        }
106
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$channel}')]")->click();
107
108
        return $this;
109
    }
110
111
    public function setB2BCustomer($customer)
112
    {