Skip to content

Commit f02714f

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-61549: Use default URL Key
1 parent 264a199 commit f02714f

File tree

4 files changed

+58
-106
lines changed

4 files changed

+58
-106
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
5858
['element' => $modalElement]
5959
);
6060
$modal->acceptAlert();
61+
$modal->waitModalWindowToDisappear();
6162
}
62-
if ($fixture->hasData('use_default_url_key')) {
63-
$this->openContainer('seo');
64-
}
65-
6663
return parent::fill($fixture, $element);
6764
}
6865
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryCheckDefaultUrl.php

Lines changed: 0 additions & 98 deletions
This file was deleted.

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryForm.php

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
1111
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex;
1212
use Magento\Mtf\Constraint\AbstractAssertForm;
13+
use Magento\Mtf\Client\Locator;
14+
use Magento\Mtf\Client\BrowserInterface;
15+
use Magento\Mtf\Block\BlockFactory;
1316

1417
/**
1518
* Assert that displayed category data on edit page equals passed from fixture.
@@ -27,31 +30,81 @@ class AssertCategoryForm extends AbstractAssertForm
2730
*/
2831
protected $skippedFixtureFields = [
2932
'parent_id',
30-
'id'
33+
'id',
34+
'store_id'
3135
];
3236

37+
/**
38+
* Default sore switcher block locator.
39+
*
40+
* @var string
41+
*/
42+
private $storeSwitcherBlock = '.store-switcher';
43+
44+
/**
45+
* Dropdown block locator.
46+
*
47+
* @var string
48+
*/
49+
private $dropdownBlock = '.dropdown';
50+
51+
/**
52+
* Selector for confirm.
53+
*
54+
* @var string
55+
*/
56+
private $confirmModal = '.confirm._show[data-role=modal]';
57+
3358
/**
3459
* Assert that displayed category data on edit page equals passed from fixture.
3560
*
3661
* @param CatalogCategoryIndex $catalogCategoryIndex
3762
* @param CatalogCategoryEdit $catalogCategoryEdit
3863
* @param Category $category
64+
* @param BrowserInterface $browser
65+
* @param BlockFactory $blockFactory
3966
* @return void
4067
*/
4168
public function processAssert(
4269
CatalogCategoryIndex $catalogCategoryIndex,
4370
CatalogCategoryEdit $catalogCategoryEdit,
44-
Category $category
71+
Category $category,
72+
BrowserInterface $browser,
73+
BlockFactory $blockFactory
4574
) {
4675
$catalogCategoryIndex->open();
4776
$catalogCategoryIndex->getTreeCategories()->selectCategory($category, true);
48-
77+
$this->switchScope($category, $browser, $blockFactory);
4978
$fixtureData = $this->prepareFixtureData($category->getData());
5079
$formData = $catalogCategoryEdit->getEditForm()->getData($category);
5180
$error = $this->verifyData($this->sortData($fixtureData), $this->sortData($formData));
5281
\PHPUnit_Framework_Assert::assertEmpty($error, $error);
5382
}
5483

84+
/**
85+
* Switches scope to selected store on the edit form
86+
*
87+
* @param Category $category
88+
* @param BrowserInterface $browser
89+
* @param BlockFactory $blockFactory
90+
* @return void
91+
*/
92+
private function switchScope(Category $category, BrowserInterface $browser, BlockFactory $blockFactory)
93+
{
94+
if ($category->hasData('store_id')) {
95+
$store = $category->getStoreId()['source']->getName();
96+
$storeSwitcherBlock = $browser->find($this->storeSwitcherBlock);
97+
$storeSwitcherBlock->find($this->dropdownBlock, Locator::SELECTOR_CSS, 'liselectstore')->setValue($store);
98+
$modalElement = $browser->find($this->confirmModal);
99+
/** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
100+
$modal = $blockFactory->create(
101+
\Magento\Ui\Test\Block\Adminhtml\Modal::class,
102+
['element' => $modalElement]
103+
);
104+
$modal->acceptAlert();
105+
}
106+
}
107+
55108
/**
56109
* Prepares fixture data for comparison.
57110
*

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<data name="category/data/store_id/dataset" xsi:type="string">custom</data>
6666
<data name="category/data/use_default_url_key" xsi:type="string">Yes</data>
6767
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
68-
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryCheckDefaultUrl" />
68+
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
6969
</variation>
7070
</testCase>
7171
</config>

0 commit comments

Comments
 (0)