Code Duplication    Length = 33-33 lines in 2 locations

src/Oro/Bundle/ContactBundle/Tests/Selenium/Pages/Contact.php 1 location

@@ 346-378 (lines=33) @@
343
            ->text();
344
    }
345
346
    public function setAddress($data, $addressId = 0)
347
    {
348
        if ($this->isElementPresent("//button[@data-action-name='add_address']")) {
349
            // click Add address button
350
            $this->test->byXpath("//button[@data-action-name='add_address']")->click();
351
            $this->waitForAjax();
352
        } elseif (!$this->isElementPresent(
353
            "//div[@data-ftid='oro_contact_form_addresses']/div[@data-content='{$addressId}' or " .
354
            "@data-content='oro_contact_form[addresses][{$addressId}]']"
355
        )
356
        ) {
357
            //click Add
358
            $addButton = $this->test->byXpath(
359
                "//div[@class='row-oro'][div[@data-ftid='oro_contact_form_addresses']]" .
360
                "//a[@class='btn add-list-item']"
361
            );
362
            $this->test->moveto($addButton);
363
            $addButton->click();
364
            $this->waitForAjax();
365
        }
366
367
        foreach ($data as $key => $value) {
368
            $method = 'setAddress' . ucfirst($key);
369
            $this->$method($value, $addressId);
370
        }
371
372
        if ($this->isElementPresent("//div[@role='dialog']")) {
373
            $this->test->byXpath("//div[@class='form-actions widget-actions']//button[@type='submit']")->click();
374
            $this->waitForAjax();
375
        }
376
377
        return $this;
378
    }
379
380
    public function getAddress(&$values, $addressId = 0)
381
    {

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

@@ 406-438 (lines=33) @@
403
            ->text();
404
    }
405
406
    public function setAddress($data, $addressId = 1)
407
    {
408
        if ($this->isElementPresent("//button[@data-action-name='add_address']")) {
409
            // click Add address button
410
            $this->test->byXpath("//button[@data-action-name='add_address']")->click();
411
            $this->waitForAjax();
412
        } elseif (!$this->isElementPresent(
413
            "//div[@data-ftid='oro_sales_lead_form_addresses']/div[@data-content='{$addressId}' or " .
414
            "@data-content='oro_sales_lead_form[addresses][{$addressId}]']"
415
        )
416
        ) {
417
            //click Add
418
            $addButton = $this->test->byXpath(
419
                "//div[@class='row-oro'][div[@data-ftid='oro_sales_lead_form_addresses']]" .
420
                "//a[@class='btn add-list-item']"
421
            );
422
            $this->test->moveto($addButton);
423
            $addButton->click();
424
            $this->waitForAjax();
425
        }
426
427
        foreach ($data as $key => $value) {
428
            $method = 'setAddress' . ucfirst($key);
429
            $this->$method($value, $addressId);
430
        }
431
432
        if ($this->isElementPresent("//div[@role='dialog']")) {
433
            $this->test->byXpath("//div[@class='form-actions widget-actions']//button[@type='submit']")->click();
434
            $this->waitForAjax();
435
        }
436
437
        return $this;
438
    }
439
440
    public function getAddress(&$values, $addressId = 0)
441
    {