Code Duplication    Length = 33-33 lines in 2 locations

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

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

src/OroCRM/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='orocrm_sales_lead_form_addresses']/div[@data-content='{$addressId}' or " .
414
            "@data-content='orocrm_sales_lead_form[addresses][{$addressId}]']"
415
        )
416
        ) {
417
            //click Add
418
            $addButton = $this->test->byXpath(
419
                "//div[@class='row-oro'][div[@data-ftid='orocrm_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
    {