Skip to content

Commit 9bca37f

Browse files
author
Dmytro Aponasenko
committed
Merge branch 'MTA-1499' into develop
Conflicts: dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails.php
2 parents 89b534f + 5d8cac2 commit 9bca37f

File tree

61 files changed

+423
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+423
-814
lines changed

dev/tests/functional/lib/Magento/Mtf/Client/Element/OptgroupselectElement.php

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,62 @@
99
use Magento\Mtf\Client\Locator;
1010

1111
/**
12-
* Class OptgroupselectElement
13-
* Typified element class for option group selectors
12+
* Typified element class for option group selectors.
1413
*/
1514
class OptgroupselectElement extends SelectElement
1615
{
1716
/**
18-
* Option group selector
17+
* Option locator.
18+
*
19+
* @var string
20+
*/
21+
protected $optionByIndex = './/option';
22+
23+
/**
24+
* Option group selector.
1925
*
2026
* @var string
2127
*/
2228
protected $optGroup = 'optgroup[option[contains(.,"%s")]]';
2329

2430
/**
25-
* Get the value of form element
31+
* Option group locator.
32+
*
33+
* @var string
34+
*/
35+
protected $optionGroupValue = ".//optgroup[@label = '%s']/option[text() = '%s']";
36+
37+
/**
38+
* Get the value of form element.
2639
*
2740
* @return string
41+
* @throws \Exception
2842
*/
2943
public function getValue()
3044
{
3145
$this->eventManager->dispatchEvent(['get_value'], [(string)$this->getAbsoluteSelector()]);
32-
$selectedLabel = trim(parent::getValue());
46+
47+
$selectedLabel = '';
48+
$labels = $this->getElements($this->optionByIndex, Locator::SELECTOR_XPATH);
49+
foreach ($labels as $label) {
50+
if ($label->isSelected()) {
51+
$selectedLabel = $label->getText();
52+
break;
53+
}
54+
}
55+
if ($selectedLabel == '') {
56+
throw new \Exception('Selected value has not been found in optgroup select.');
57+
}
58+
3359
$element = $this->find(sprintf($this->optGroup, $selectedLabel), Locator::SELECTOR_XPATH);
3460
$value = trim($element->getAttribute('label'), chr(0xC2) . chr(0xA0));
3561
$value .= '/' . $selectedLabel;
62+
3663
return $value;
3764
}
3865

3966
/**
40-
* Select value in dropdown which has option groups
67+
* Select value in dropdown which has option groups.
4168
*
4269
* @param string $value
4370
* @return void
@@ -46,6 +73,8 @@ public function setValue($value)
4673
{
4774
$this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
4875
list($group, $option) = explode('/', $value);
49-
parent::setOptionGroupValue($group, $option);
76+
$xpath = sprintf($this->optionGroupValue, $group, $option);
77+
$option = $this->find($xpath, Locator::SELECTOR_XPATH);
78+
$option->click();
5079
}
5180
}

dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectstoreElement.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
*/
1414
class SelectstoreElement extends SelectElement
1515
{
16+
/**
17+
* Option locator
18+
*
19+
* @var string
20+
*/
21+
protected $optionByIndex = './/optgroup/option[%d]';
22+
1623
/**
1724
* Store option group selector.
1825
*

dev/tests/functional/lib/Magento/Mtf/Util/Protocol/CurlTransport/FrontendDecorator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Magento\Mtf\Util\Protocol\CurlTransport;
88

9-
use Magento\Customer\Test\Fixture\CustomerInjectable;
9+
use Magento\Customer\Test\Fixture\Customer;
1010
use Magento\Mtf\Util\Protocol\CurlInterface;
1111
use Magento\Mtf\Util\Protocol\CurlTransport;
1212

@@ -48,9 +48,9 @@ class FrontendDecorator implements CurlInterface
4848
* Constructor
4949
*
5050
* @param CurlTransport $transport
51-
* @param CustomerInjectable $customer
51+
* @param Customer $customer
5252
*/
53-
public function __construct(CurlTransport $transport, CustomerInjectable $customer)
53+
public function __construct(CurlTransport $transport, Customer $customer)
5454
{
5555
$this->transport = $transport;
5656
$this->authorize($customer);
@@ -59,11 +59,11 @@ public function __construct(CurlTransport $transport, CustomerInjectable $custom
5959
/**
6060
* Authorize customer on frontend
6161
*
62-
* @param CustomerInjectable $customer
62+
* @param Customer $customer
6363
* @throws \Exception
6464
* @return void
6565
*/
66-
protected function authorize(CustomerInjectable $customer)
66+
protected function authorize(Customer $customer)
6767
{
6868
$url = $_ENV['app_frontend_url'] . 'customer/account/login/';
6969
$this->transport->write(CurlInterface::POST, $url);

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/CheckoutData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ protected function getPreset($name)
7070
],
7171
],
7272
],
73-
'qty' => 2,
73+
'qty' => 1,
7474
'cartItem' => [
7575
'price' => 756,
76-
'qty' => 2,
76+
'qty' => 1,
7777
'subtotal' => 756,
7878
],
7979
],

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/Price.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public function getDataConfig()
9292
* Get preset array
9393
*
9494
* @return array|null
95+
*
96+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
9597
*/
9698
public function getPreset()
9799
{

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/AbstractConfigureBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function prepareCheckoutData(array $options, array $checkoutData)
9797

9898
if (isset($options[$attribute])) {
9999
$result[] = [
100-
'type' => strtolower(preg_replace('/[^a-z]/i', '', $options[$attribute]['type'])),
100+
'type' => $options[$attribute]['type'],
101101
'title' => isset($options[$attribute]['title'])
102102
? $options[$attribute]['title']
103103
: $attribute,

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ class AttributeForm extends FormTabs
3636
*/
3737
protected $saveButton = '#save';
3838

39+
/**
40+
* Attribute to determine whether tab is opened.
41+
*
42+
* @var string
43+
*/
44+
protected $isTabOpened = '.opened ';
45+
3946
/**
4047
* @constructor
4148
* @param SimpleElement $element
@@ -88,8 +95,11 @@ public function openTab($tabName)
8895
$strategy = isset($this->tabs[$tabName]['strategy'])
8996
? $this->tabs[$tabName]['strategy']
9097
: Locator::SELECTOR_CSS;
91-
$tab = $this->_rootElement->find($selector, $strategy);
92-
$tab->click();
98+
99+
$isTabOpened = $this->_rootElement->find($this->isTabOpened . $selector, $strategy);
100+
if (!$isTabOpened->isVisible()) {
101+
$this->_rootElement->find($selector, $strategy)->click();
102+
}
93103

94104
return $this;
95105
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</fields>
2929
</properties>
3030
<advanced-properties>
31-
<class>\Magento\Catalog\Test\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced</class>
31+
<class>\Magento\Backend\Test\Block\Widget\Tab</class>
3232
<selector>[data-target="#advanced_fieldset-content"]</selector>
3333
<strategy>css selector</strategy>
3434
<fields>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/AttributeForm.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class AttributeForm extends FormTabs
3333
*/
3434
protected $propertiesTab = '#product_attribute_tabs_main';
3535

36+
/**
37+
* Page title.
38+
*
39+
* @var string
40+
*/
41+
protected $pageTitle = '.page-title .title';
42+
3643
/**
3744
* Get data of the tabs.
3845
*
@@ -94,15 +101,8 @@ protected function expandAllToggles()
94101
*/
95102
public function openTab($tabName)
96103
{
97-
$selector = $this->tabs[$tabName]['selector'];
98-
$strategy = isset($this->tabs[$tabName]['strategy'])
99-
? $this->tabs[$tabName]['strategy']
100-
: Locator::SELECTOR_CSS;
101-
$tab = $this->_rootElement->find($selector, $strategy);
102-
$target = $this->browser->find('.page-title .title');// Handle menu overlap problem
103-
$this->_rootElement->dragAndDrop($target);
104-
$tab->click();
105-
return $this;
104+
$this->browser->find($this->pageTitle)->click(); // Handle menu overlap problem
105+
return parent::openTab($tabName);
106106
}
107107

108108
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,17 @@ protected function prepareCustomOptions(array $options)
204204
/**
205205
* Convert option name
206206
*
207-
* @param string $str
207+
* @param string $inputType
208208
* @return string
209209
*/
210-
protected function optionNameConvert($str)
210+
protected function optionNameConvert($inputType)
211211
{
212-
$str = str_replace([' ', '&'], "", $str);
213-
if ($end = strpos($str, '-')) {
214-
$str = substr($str, 0, $end) . ucfirst(substr($str, ($end + 1)));
212+
$option = substr($inputType, strpos($inputType, "/") + 1);
213+
$option = str_replace([' ', '&'], "", $option);
214+
if ($end = strpos($option, '-')) {
215+
$option = substr($option, 0, $end) . ucfirst(substr($option, ($end + 1)));
215216
}
216217

217-
return $str;
218+
return $option;
218219
}
219220
}

0 commit comments

Comments
 (0)