1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Magium\Magento\Navigators\Admin; |
4
|
|
|
|
5
|
|
|
use Magium\Magento\AbstractMagentoTestCase; |
6
|
|
|
use Magium\Magento\Actions\Admin\Tables\ClearTableFilters; |
7
|
|
|
use Magium\Magento\Actions\Admin\Tables\ClickButton; |
8
|
|
|
use Magium\Magento\Actions\Admin\WaitForLoadingMask; |
9
|
|
|
use Magium\Magento\Navigators\Admin\Customer\AbstractCustomerNavigation; |
10
|
|
|
use Magium\Magento\Themes\Admin\ThemeConfiguration; |
11
|
|
|
use Magium\Navigators\NavigatorInterface; |
12
|
|
|
use Magium\WebDriver\ExpectedCondition; |
13
|
|
|
use Magium\WebDriver\WebDriver; |
14
|
|
|
|
15
|
|
|
class Customer implements NavigatorInterface |
16
|
|
|
{ |
17
|
|
|
const NAVIGATOR = 'Admin\Customer'; |
18
|
|
|
|
19
|
|
|
protected $webDriver; |
20
|
|
|
protected $themeConfiguration; |
21
|
|
|
protected $adminLogin; |
22
|
|
|
protected $adminMenuNavigator; |
23
|
|
|
protected $clearTableFilters; |
24
|
|
|
protected $clickButton; |
25
|
|
|
protected $waitForLoadingMask; |
26
|
|
|
protected $testCase; |
27
|
|
|
|
28
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
29
|
|
|
WebDriver $webDriver, |
30
|
|
|
ThemeConfiguration $themeConfiguration, |
31
|
|
|
AdminMenu $adminMenuNavigator, |
32
|
|
|
ClearTableFilters $clearTableFilters, |
33
|
|
|
ClickButton $clickButton, |
34
|
|
|
WaitForLoadingMask $waitForLoadingMask, |
35
|
|
|
AbstractMagentoTestCase $testCase |
36
|
|
|
) |
37
|
|
|
{ |
38
|
|
|
$this->webDriver = $webDriver; |
39
|
|
|
$this->themeConfiguration = $themeConfiguration; |
40
|
|
|
$this->adminMenuNavigator = $adminMenuNavigator; |
41
|
|
|
$this->clearTableFilters = $clearTableFilters; |
42
|
|
|
$this->clickButton = $clickButton; |
43
|
|
|
$this->waitForLoadingMask = $waitForLoadingMask; |
44
|
|
|
$this->testCase = $testCase; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function navigateTo(AbstractCustomerNavigation $navigation) |
48
|
|
|
{ |
49
|
|
|
|
50
|
|
|
$this->adminMenuNavigator->navigateTo('Customers/Manage Customers'); |
51
|
|
|
|
52
|
|
|
$this->clearTableFilters->clear(); |
53
|
|
|
|
54
|
|
|
$parts = explode('-', $navigation->getSelectorID()); |
55
|
|
|
foreach ($parts as $part) { |
56
|
|
|
$element = $this->webDriver->byId($part); |
57
|
|
|
$element->sendKeys($navigation->getSearch()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$this->clickButton->click($this->themeConfiguration->getSearchButtonText()); |
61
|
|
|
$this->testCase->sleep('100ms'); |
62
|
|
|
$this->waitForLoadingMask->wait(); |
63
|
|
|
|
64
|
|
|
$selectXpath = $this->themeConfiguration->getSelectCustomerXpath($navigation->getSearch()); |
65
|
|
|
|
66
|
|
|
$this->testCase->assertElementDisplayed($selectXpath, WebDriver::BY_XPATH); |
67
|
|
|
$element = $this->webDriver->byXpath($selectXpath); |
68
|
|
|
|
69
|
|
|
$element->click(); |
70
|
|
|
$elementExists = $this->testCase->getTranslator()->translatePlaceholders('//h4[.="{{Personal Information}}"]'); |
71
|
|
|
$this->webDriver->wait()->until(ExpectedCondition::elementExists($elementExists, WebDriver::BY_XPATH)); |
|
|
|
|
72
|
|
|
|
73
|
|
|
$element = $this->webDriver->byXpath($elementExists); |
74
|
|
|
|
75
|
|
|
$this->webDriver->wait()->until(ExpectedCondition::visibilityOf($element)); |
|
|
|
|
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
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.