Code Duplication    Length = 21-22 lines in 6 locations

src/OroCRM/Bundle/ContactBundle/Tests/Selenium/Pages/Contact.php 4 locations

@@ 244-265 (lines=22) @@
241
        return $zipcode->attribute('value');
242
    }
243
244
    public function setAddressCountry($value, $addressId = 0)
245
    {
246
        $country = "//div[starts-with(@id,'s2id_orocrm_contact_form_addresses_{$addressId}_country')]/a";
247
        if ($this->isElementPresent("//div[@role='dialog']")) {
248
            $country = "//div[starts-with(@id,'s2id_orocrm_contact_address_form_country')]/a";
249
        }
250
        $country = $this->test->byXpath($country);
251
        $this->test->moveto($country);
252
253
        $country->click();
254
        $this->waitForAjax();
255
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($value);
256
        $this->waitForAjax();
257
        $this->assertElementPresent(
258
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']",
259
            "Country's autocomplete doesn't return search value"
260
        );
261
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']")->click();
262
        $this->waitForAjax();
263
264
        return $this;
265
    }
266
267
    public function typeAddressCountry($value, $addressId = 0)
268
    {
@@ 267-288 (lines=22) @@
264
        return $this;
265
    }
266
267
    public function typeAddressCountry($value, $addressId = 0)
268
    {
269
        $country = "//div[starts-with(@id,'s2id_orocrm_contact_form_addresses_{$addressId}_country')]/a";
270
        if ($this->isElementPresent("//div[@role='dialog']")) {
271
            $country = "//div[starts-with(@id,'s2id_orocrm_contact_address_form_country')]/a";
272
        }
273
        $country = $this->test->byXpath($country);
274
        $this->test->moveto($country);
275
276
        $country->click();
277
        $this->waitForAjax();
278
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($value);
279
        $this->waitForAjax();
280
        $this->assertElementPresent(
281
            "//div[@id='select2-drop']//div[contains(., '{$value}')]",
282
            "Country's autocomplete doesn't return search value"
283
        );
284
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$value}')]")->click();
285
        $this->waitForAjax();
286
287
        return $this;
288
    }
289
290
    public function getAddressCountry($addressId = 0)
291
    {
@@ 297-317 (lines=21) @@
294
            ->text();
295
    }
296
297
    public function setAddressRegion($region, $addressId = 0)
298
    {
299
        $xpath = "//div[starts-with(@id,'s2id_orocrm_contact_form_addresses_{$addressId}_region')]/a";
300
        if ($this->isElementPresent("//div[@role='dialog']")) {
301
            $xpath = "//div[starts-with(@id,'s2id_orocrm_contact_address_form_region')]/a";
302
        }
303
        $xpath = $this->test->byXpath($xpath);
304
        $this->test->moveto($xpath);
305
306
        $xpath->click();
307
        $this->waitForAjax();
308
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($region);
309
        $this->waitForAjax();
310
        $this->assertElementPresent(
311
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']",
312
            "Country's autocopmlete doesn't return search value"
313
        );
314
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']")->click();
315
316
        return $this;
317
    }
318
319
    public function typeAddressRegion($region, $addressId = 0)
320
    {
@@ 319-339 (lines=21) @@
316
        return $this;
317
    }
318
319
    public function typeAddressRegion($region, $addressId = 0)
320
    {
321
        $xpath = "//div[starts-with(@id,'s2id_orocrm_contact_form_addresses_{$addressId}_region')]/a";
322
        if ($this->isElementPresent("//div[@role='dialog']")) {
323
            $xpath = "//div[starts-with(@id,'s2id_orocrm_contact_address_form_region')]/a";
324
        }
325
        $xpath = $this->test->byXpath($xpath);
326
        $this->test->moveto($xpath);
327
328
        $xpath->click();
329
        $this->waitForAjax();
330
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($region);
331
        $this->waitForAjax();
332
        $this->assertElementPresent(
333
            "//div[@id='select2-drop']//div[contains(., '{$region}')]",
334
            "Country's autocopmlete doesn't return search value"
335
        );
336
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$region}')]")->click();
337
338
        return $this;
339
    }
340
341
    public function getAddressRegion($addressId = 0)
342
    {

src/OroCRM/Bundle/SalesBundle/Tests/Selenium/Pages/Lead.php 2 locations

@@ 347-368 (lines=22) @@
344
        return $zipcode->attribute('value');
345
    }
346
347
    public function setAddressCountry($value, $addressId = 0)
348
    {
349
        $country = "//div[starts-with(@id,'s2id_orocrm_sales_lead_form_addresses_{$addressId}_country')]/a";
350
        if ($this->isElementPresent("//div[@role='dialog']")) {
351
            $country = "//div[starts-with(@id,'s2id_orocrm_sales_lead_address_form_country')]/a";
352
        }
353
        $country = $this->test->byXpath($country);
354
        $this->test->moveto($country);
355
356
        $country->click();
357
        $this->waitForAjax();
358
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($value);
359
        $this->waitForAjax();
360
        $this->assertElementPresent(
361
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']",
362
            "Country's autocomplete doesn't return search value"
363
        );
364
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']")->click();
365
        $this->waitForAjax();
366
367
        return $this;
368
    }
369
370
    public function getAddressCountry($addressId = 0)
371
    {
@@ 377-397 (lines=21) @@
374
            ->text();
375
    }
376
377
    public function setAddressRegion($region, $addressId = 0)
378
    {
379
        $xpath = "//div[starts-with(@id,'s2id_orocrm_sales_lead_form_addresses_{$addressId}_region')]/a";
380
        if ($this->isElementPresent("//div[@role='dialog']")) {
381
            $xpath = "//div[starts-with(@id,'s2id_orocrm_sales_lead_address_form_region')]/a";
382
        }
383
        $xpath = $this->test->byXpath($xpath);
384
        $this->test->moveto($xpath);
385
386
        $xpath->click();
387
        $this->waitForAjax();
388
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($region);
389
        $this->waitForAjax();
390
        $this->assertElementPresent(
391
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']",
392
            "Country's autocopmlete doesn't return search value"
393
        );
394
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']")->click();
395
396
        return $this;
397
    }
398
399
    public function getAddressRegion($addressId = 0)
400
    {