Skip to content

Commit 262ba0e

Browse files
author
Dmytro Aponasenko
committed
Merge branch 'MTA-2483' of https://github.corp.ebay.com/magento-qmt/magento2ce into develop
2 parents 9e36926 + 5b81c10 commit 262ba0e

File tree

7 files changed

+167
-9
lines changed

7 files changed

+167
-9
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/Block/Adminhtml/Category/Edit/PageActions.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
use Magento\Backend\Test\Block\FormPageActions;
1010

1111
/**
12-
* Class PageActions
13-
* Category page actions
12+
* Category page actions.
1413
*/
1514
class PageActions extends FormPageActions
1615
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Constraint;
8+
9+
use Magento\Catalog\Test\Fixture\Category;
10+
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11+
use Magento\Mtf\Client\BrowserInterface;
12+
use Magento\Mtf\Constraint\AbstractConstraint;
13+
use Magento\Cms\Test\Page\CmsIndex;
14+
15+
/**
16+
* Assert that category name is different on different store view.
17+
*/
18+
class AssertCategoryWithCustomStoreOnFrontend extends AbstractConstraint
19+
{
20+
/**
21+
* Assert that category name is different on different store view.
22+
*
23+
* @param BrowserInterface $browser
24+
* @param CatalogCategoryView $categoryView
25+
* @param Category $category
26+
* @param Category $initialCategory
27+
* @param CmsIndex $cmsIndex
28+
* @return void
29+
*/
30+
public function processAssert(
31+
BrowserInterface $browser,
32+
CatalogCategoryView $categoryView,
33+
Category $category,
34+
Category $initialCategory,
35+
CmsIndex $cmsIndex
36+
) {
37+
$cmsIndex->open();
38+
$cmsIndex->getLinksBlock()->waitWelcomeMessage();
39+
$browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
40+
\PHPUnit_Framework_Assert::assertEquals(
41+
$initialCategory->getName(),
42+
$categoryView->getTitleBlock()->getTitle(),
43+
'Wrong category name is displayed for default store.'
44+
);
45+
46+
$store = $category->getDataFieldConfig('store_id')['source']->store->getName();
47+
$cmsIndex->getStoreSwitcherBlock()->selectStoreView($store);
48+
$cmsIndex->getLinksBlock()->waitWelcomeMessage();
49+
$browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
50+
\PHPUnit_Framework_Assert::assertEquals(
51+
$category->getName(),
52+
$categoryView->getTitleBlock()->getTitle(),
53+
'Wrong category name is displayed for ' . $store
54+
);
55+
}
56+
57+
/**
58+
* Returns a string representation of the object.
59+
*
60+
* @return string
61+
*/
62+
public function toString()
63+
{
64+
return 'Category name is different on different store view.';
65+
}
66+
}

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.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,11 @@
4646
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
4747
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
4848
</variation>
49+
<variation name="UpdateCategoryEntityTestVariation4" summary="Update Category with custom Store View.">
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>
52+
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
53+
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryWithCustomStoreOnFrontend" />
54+
</variation>
4955
</testCase>
5056
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,9 @@
151151
<argument name="severity" xsi:type="string">high</argument>
152152
</arguments>
153153
</type>
154+
<type name="Magento\Catalog\Test\Constraint\AssertCategoryWithCustomStoreOnFrontend">
155+
<arguments>
156+
<argument name="severity" xsi:type="string">low</argument>
157+
</arguments>
158+
</type>
154159
</config>

0 commit comments

Comments
 (0)