Skip to content

Commit baae745

Browse files
committed
MTA-2483: Extend Update Category
- Changed type of setting store view.
1 parent 1582006 commit baae745

File tree

6 files changed

+105
-22
lines changed

6 files changed

+105
-22
lines changed

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,32 @@
77
namespace Magento\Catalog\Test\Block\Adminhtml\Category\Edit;
88

99
use Magento\Backend\Test\Block\Widget\FormTabs;
10+
use Magento\Mtf\Client\Element\SimpleElement;
11+
use Magento\Mtf\Client\Locator;
1012
use Magento\Mtf\Factory\Factory;
13+
use Magento\Mtf\Fixture\FixtureInterface;
1114

1215
/**
13-
* Class CategoryForm
14-
* Category container block
16+
* Category container block.
1517
*/
1618
class CategoryForm extends FormTabs
1719
{
1820
/**
19-
* Save button
21+
* Default sore switcher block locator.
2022
*
2123
* @var string
2224
*/
23-
protected $saveButton = '[data-ui-id=category-edit-form-save-button]';
25+
protected $storeSwitcherBlock = '.store-switcher';
2426

2527
/**
26-
* Category Products grid
28+
* Dropdown block locator.
2729
*
2830
* @var string
2931
*/
30-
protected $productsGridBlock = '#catalog_category_products';
32+
protected $dropdownBlock = '.dropdown';
3133

3234
/**
33-
* Get Category edit form
35+
* Get Category edit form.
3436
*
3537
* @return \Magento\Catalog\Test\Block\Adminhtml\Category\Tab\ProductGrid
3638
*/
@@ -40,4 +42,25 @@ public function getCategoryProductsGrid()
4042
$this->_rootElement->find($this->productsGridBlock)
4143
);
4244
}
45+
46+
/**
47+
* Fill form with tabs.
48+
*
49+
* @param FixtureInterface $fixture
50+
* @param SimpleElement|null $element
51+
* @return FormTabs
52+
*/
53+
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
54+
{
55+
$tabs = $this->getFieldsByTabs($fixture);
56+
if ($fixture->hasData('store_id')) {
57+
$store = $fixture->getStoreId();
58+
$storeSwitcherBlock = $this->browser->find($this->storeSwitcherBlock);
59+
$storeSwitcherBlock->find($this->dropdownBlock, Locator::SELECTOR_CSS, 'liselectstore')->setValue($store);
60+
$this->browser->acceptAlert();
61+
62+
}
63+
64+
return $this->fillTabs($tabs, $element);
65+
}
4366
}

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
1111
use Magento\Mtf\Client\BrowserInterface;
1212
use Magento\Mtf\Constraint\AbstractConstraint;
13-
use Magento\Store\Test\Fixture\Store;
1413
use Magento\Cms\Test\Page\CmsIndex;
1514

1615
/**
@@ -28,26 +27,34 @@ class AssertCategoryWithCustomStoreOnFrontend extends AbstractConstraint
2827
* @param BrowserInterface $browser
2928
* @param CatalogCategoryView $categoryView
3029
* @param Category $category
31-
* @param Store $store
30+
* @param Category $initialCategory
3231
* @param CmsIndex $cmsIndex
3332
* @return void
3433
*/
3534
public function processAssert(
3635
BrowserInterface $browser,
3736
CatalogCategoryView $categoryView,
3837
Category $category,
39-
Store $store,
38+
Category $initialCategory,
4039
CmsIndex $cmsIndex
4140
) {
4241
$cmsIndex->open();
4342
$cmsIndex->getLinksBlock()->waitWelcomeMessage();
44-
$cmsIndex->getStoreSwitcherBlock()->selectStoreView($store->getName());
43+
$browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
44+
\PHPUnit_Framework_Assert::assertEquals(
45+
$initialCategory->getName(),
46+
$categoryView->getTitleBlock()->getTitle(),
47+
'Wrong page is displayed on default store.'
48+
);
49+
50+
$store = $category->getDataFieldConfig('store_id')['source']->store->getName();
51+
$cmsIndex->getStoreSwitcherBlock()->selectStoreView($store);
4552
$cmsIndex->getLinksBlock()->waitWelcomeMessage();
46-
$browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
53+
$browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
4754
\PHPUnit_Framework_Assert::assertEquals(
4855
$category->getName(),
4956
$categoryView->getTitleBlock()->getTitle(),
50-
'Wrong page is displayed.'
57+
'Wrong page is displayed on ' . $store
5158
);
5259
}
5360

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@
4141
<field name="landing_page" group="display_setting" source="Magento\Catalog\Test\Fixture\Category\LandingPage" />
4242
<field name="display_mode" group="display_setting" />
4343
<field name="category_products" group="category_products" source="Magento\Catalog\Test\Fixture\Category\CategoryProducts" />
44+
<field name="store_id" group="null" source="Magento\Catalog\Test\Fixture\Category\StoreId" />
4445
</fixture>
4546
</config>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Fixture\Category;
8+
9+
use Magento\Mtf\Fixture\DataSource;
10+
use Magento\Mtf\Fixture\FixtureFactory;
11+
use Magento\Store\Test\Fixture\Store;
12+
use Magento\Store\Test\Fixture\StoreGroup;
13+
14+
/**
15+
* Category store id scope.
16+
*/
17+
class StoreId extends DataSource
18+
{
19+
/**
20+
* Store fixture.
21+
*
22+
* @var Store
23+
*/
24+
public $store;
25+
26+
/**
27+
* @constructor
28+
* @param FixtureFactory $fixtureFactory
29+
* @param array $params
30+
* @param array $data [optional]
31+
*/
32+
public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
33+
{
34+
$this->params = $params;
35+
36+
if (isset($data['dataset'])) {
37+
$store = $fixtureFactory->createByCode('store', $data);
38+
/** @var Store $store */
39+
if (!$store->getStoreId()) {
40+
$store->persist();
41+
}
42+
$this->store = $store;
43+
$this->data = $store->getGroupId() . '/' . $store->getName();
44+
} else {
45+
$this->data = $data;
46+
}
47+
}
48+
49+
/**
50+
* Return Store fixture.
51+
*
52+
* @return Store
53+
*/
54+
public function getStore()
55+
{
56+
return $this->store;
57+
}
58+
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
1111
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex;
1212
use Magento\Mtf\TestCase\Injectable;
13-
use Magento\Store\Test\Fixture\Store;
1413

1514
/**
1615
* Test Creation for UpdateCategoryEntity
@@ -75,12 +74,10 @@ public function __inject(
7574
*
7675
* @param Category $category
7776
* @param Category $initialCategory
78-
* @param Store $store
7977
* @return void
8078
*/
81-
public function test(Category $category, Category $initialCategory, Store $store)
79+
public function test(Category $category, Category $initialCategory)
8280
{
83-
$store->persist();
8481
$this->catalogCategoryIndex->open();
8582
$this->catalogCategoryIndex->getTreeCategories()->selectCategory($initialCategory);
8683
$this->catalogCategoryEdit->getEditForm()->fill($category);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@
4747
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
4848
</variation>
4949
<variation name="UpdateCategoryEntityTestVariation4">
50-
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
51-
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
52-
<data name="category/data/url_key" xsi:type="string">UrlKey%isolation%</data>
53-
<data name="category/data/is_active" xsi:type="string">Yes</data>
54-
<data name="store/dataset" xsi:type="string">custom</data>
50+
<data name="category/data/store_id/dataset" xsi:type="string">custom</data>
51+
<data name="category/data/name" xsi:type="string">Category %isolation%</data>
5552
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
5653
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryWithCustomStoreOnFrontend" />
5754
</variation>

0 commit comments

Comments
 (0)