Skip to content

Commit 1afd2fb

Browse files
author
Igor Melnikov
committed
Merge branch 'upstream-develop' into MAGETWO-46577-functional-test-https
2 parents 22e60bd + 5d5738a commit 1afd2fb

File tree

20 files changed

+444
-248
lines changed

20 files changed

+444
-248
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ public function execute()
5959
if ($storeId) {
6060
$categoryId = (int)$this->storeManager->getStore($storeId)->getRootCategoryId();
6161
} else {
62-
$categoryId = (int)$this->storeManager->getDefaultStoreView()->getRootCategoryId();
62+
$defaultStoreView = $this->storeManager->getDefaultStoreView();
63+
if ($defaultStoreView) {
64+
$categoryId = (int)$defaultStoreView->getRootCategoryId();
65+
} else {
66+
$stores = $this->storeManager->getStores();
67+
if (count($stores)) {
68+
$store = reset($stores);
69+
$categoryId = (int)$store->getRootCategoryId();
70+
}
71+
}
6372
}
6473
$this->getRequest()->setParam('id', $categoryId);
6574
}

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Template.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
*/
1515
class Template extends Block
1616
{
17+
/**
18+
* Magento new loader.
19+
*
20+
* @var string
21+
*/
22+
protected $spinner = '[data-role="spinner"]';
23+
1724
/**
1825
* Magento loader.
1926
*
@@ -35,6 +42,7 @@ class Template extends Block
3542
*/
3643
public function waitLoader()
3744
{
45+
$this->waitForElementNotVisible($this->spinner);
3846
$this->waitForElementNotVisible($this->loader);
3947
$this->waitForElementNotVisible($this->loaderOld);
4048
}

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,46 @@
101101
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::div[@id='catalog_category_products']]</selector>
102102
<strategy>xpath</strategy>
103103
</category_products>
104-
<custom_design>
104+
<design>
105+
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
106+
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::select[@name='page_layout']]</selector>
107+
<strategy>xpath</strategy>
108+
<fields>
109+
<use_parent_category_settings>
110+
<input>checkbox</input>
111+
<selector>input[name='custom_use_parent_settings']</selector>
112+
</use_parent_category_settings>
113+
<layout>
114+
<input>select</input>
115+
<selector>select[name='page_layout']</selector>
116+
</layout>
117+
<layout_update_xml>
118+
<input>textarea</input>
119+
<selector>textarea[name='custom_layout_update']</selector>
120+
</layout_update_xml>
121+
<apply_design_to_products>
122+
<input>checkbox</input>
123+
<selector>input[name='custom_apply_to_products']</selector>
124+
</apply_design_to_products>
125+
</fields>
126+
</design>
127+
<schedule_design_update>
105128
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
106129
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::input[@name='custom_design_to']]</selector>
107130
<strategy>xpath</strategy>
108-
</custom_design>
131+
<fields>
132+
<schedule_update_from>
133+
<input>text</input>
134+
<selector>input[name='custom_design_from']</selector>
135+
</schedule_update_from>
136+
<schedule_update_to>
137+
<input>text</input>
138+
<selector>input[name='custom_design_to']</selector>
139+
</schedule_update_to>
140+
<new_theme>
141+
<input>select</input>
142+
<selector>select[name='custom_design']</selector>
143+
</new_theme>
144+
</fields>
145+
</schedule_design_update>
109146
</sections>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class Tree extends Block
5353
*/
5454
protected $treeElement = '.tree-holder';
5555

56+
/**
57+
* Page header selector.
58+
*
59+
* @var string
60+
*/
61+
protected $header = 'header';
62+
5663
/**
5764
* Get backend abstract block.
5865
*
@@ -73,6 +80,7 @@ protected function getTemplateBlock()
7380
*/
7481
public function addSubcategory()
7582
{
83+
$this->browser->find($this->header)->hover();
7684
$this->_rootElement->find($this->addSubcategory, Locator::SELECTOR_CSS)->click();
7785
$this->getTemplateBlock()->waitLoader();
7886
}
@@ -84,6 +92,7 @@ public function addSubcategory()
8492
*/
8593
public function addRootCategory()
8694
{
95+
$this->browser->find($this->header)->hover();
8796
$this->_rootElement->find($this->addRootCategory, Locator::SELECTOR_CSS)->click();
8897
$this->getTemplateBlock()->waitLoader();
8998
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class AssertCategoryForm extends AbstractAssertForm
2626
* @var array
2727
*/
2828
protected $skippedFixtureFields = [
29-
'parent_id'
29+
'parent_id',
30+
'id'
3031
];
3132

3233
/**

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

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,68 @@
66

77
namespace Magento\Catalog\Test\Constraint;
88

9+
use Magento\Mtf\Constraint\AbstractConstraint;
910
use Magento\Catalog\Test\Fixture\Category;
10-
use Magento\Cms\Test\Page\CmsIndex;
11+
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
1112
use Magento\Mtf\Client\BrowserInterface;
12-
use Magento\Mtf\Constraint\AbstractConstraint;
1313

1414
/**
1515
* Class AssertCategoryIsNotActive
16-
* Assert that the category cannot be accessed from the navigation bar in the frontend
16+
* Assert that the category cannot be accessed using the direct URL and from the navigation bar in the frontend
1717
*/
1818
class AssertCategoryIsNotActive extends AbstractConstraint
1919
{
2020
const NOT_FOUND_MESSAGE = 'Whoops, our bad...';
2121

2222
/**
23-
* Assert that the category cannot be accessed from the navigation bar in the frontend
23+
* Assert that the category cannot be accessed using the direct URL and from the navigation bar in the frontend
2424
*
25-
* @param CmsIndex $cmsIndex
2625
* @param Category $category
26+
* @param CatalogCategoryView $categoryView
2727
* @param BrowserInterface $browser
2828
* @return void
2929
*/
30-
public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser)
31-
{
32-
$cmsIndex->open();
30+
public function processAssert(
31+
Category $category,
32+
CatalogCategoryView $categoryView,
33+
BrowserInterface $browser
34+
) {
35+
$browser->open($this->getCategoryUrl($category));
3336
\PHPUnit_Framework_Assert::assertFalse(
34-
$cmsIndex->getTopmenu()->isCategoryVisible($category->getName()),
37+
$categoryView->getTopmenu()->isCategoryVisible($category->getName()),
3538
'Category can be accessed from the navigation bar in the frontend.'
3639
);
37-
$browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
3840
\PHPUnit_Framework_Assert::assertEquals(
3941
self::NOT_FOUND_MESSAGE,
40-
$cmsIndex->getTitleBlock()->getTitle(),
42+
$categoryView->getTitleBlock()->getTitle(),
4143
'Wrong page is displayed.'
4244
);
4345
}
4446

47+
/**
48+
* Get category url to open.
49+
*
50+
* @param Category $category
51+
* @return string
52+
*/
53+
protected function getCategoryUrl(Category $category)
54+
{
55+
$categoryUrlKey = [];
56+
while ($category) {
57+
$categoryUrlKey[] = $category->hasData('url_key')
58+
? strtolower($category->getUrlKey())
59+
: trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
60+
61+
$category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
62+
if (1 == $category->getParentId()) {
63+
$category = null;
64+
}
65+
}
66+
67+
return $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html';
68+
}
69+
70+
4571
/**
4672
* Category not find in top menu
4773
*

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

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

0 commit comments

Comments
 (0)