Skip to content

Commit

Permalink
Merge pull request #324 from magento-troll/MAGETWO-48042
Browse files Browse the repository at this point in the history
[Troll] Bugfixes
  • Loading branch information
Ganin, Roman(rganin) committed Jan 21, 2016
2 parents f93f18f + fa80010 commit 5d5738a
Show file tree
Hide file tree
Showing 20 changed files with 444 additions and 248 deletions.
11 changes: 10 additions & 1 deletion app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ public function execute()
if ($storeId) {
$categoryId = (int)$this->storeManager->getStore($storeId)->getRootCategoryId();
} else {
$categoryId = (int)$this->storeManager->getDefaultStoreView()->getRootCategoryId();
$defaultStoreView = $this->storeManager->getDefaultStoreView();
if ($defaultStoreView) {
$categoryId = (int)$defaultStoreView->getRootCategoryId();
} else {
$stores = $this->storeManager->getStores();
if (count($stores)) {
$store = reset($stores);
$categoryId = (int)$store->getRootCategoryId();
}
}
}
$this->getRequest()->setParam('id', $categoryId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
*/
class Template extends Block
{
/**
* Magento new loader.
*
* @var string
*/
protected $spinner = '[data-role="spinner"]';

/**
* Magento loader.
*
Expand All @@ -35,6 +42,7 @@ class Template extends Block
*/
public function waitLoader()
{
$this->waitForElementNotVisible($this->spinner);
$this->waitForElementNotVisible($this->loader);
$this->waitForElementNotVisible($this->loaderOld);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,46 @@
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::div[@id='catalog_category_products']]</selector>
<strategy>xpath</strategy>
</category_products>
<custom_design>
<design>
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::select[@name='page_layout']]</selector>
<strategy>xpath</strategy>
<fields>
<use_parent_category_settings>
<input>checkbox</input>
<selector>input[name='custom_use_parent_settings']</selector>
</use_parent_category_settings>
<layout>
<input>select</input>
<selector>select[name='page_layout']</selector>
</layout>
<layout_update_xml>
<input>textarea</input>
<selector>textarea[name='custom_layout_update']</selector>
</layout_update_xml>
<apply_design_to_products>
<input>checkbox</input>
<selector>input[name='custom_apply_to_products']</selector>
</apply_design_to_products>
</fields>
</design>
<schedule_design_update>
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::input[@name='custom_design_to']]</selector>
<strategy>xpath</strategy>
</custom_design>
<fields>
<schedule_update_from>
<input>text</input>
<selector>input[name='custom_design_from']</selector>
</schedule_update_from>
<schedule_update_to>
<input>text</input>
<selector>input[name='custom_design_to']</selector>
</schedule_update_to>
<new_theme>
<input>select</input>
<selector>select[name='custom_design']</selector>
</new_theme>
</fields>
</schedule_design_update>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class Tree extends Block
*/
protected $treeElement = '.tree-holder';

/**
* Page header selector.
*
* @var string
*/
protected $header = 'header';

/**
* Get backend abstract block.
*
Expand All @@ -73,6 +80,7 @@ protected function getTemplateBlock()
*/
public function addSubcategory()
{
$this->browser->find($this->header)->hover();
$this->_rootElement->find($this->addSubcategory, Locator::SELECTOR_CSS)->click();
$this->getTemplateBlock()->waitLoader();
}
Expand All @@ -84,6 +92,7 @@ public function addSubcategory()
*/
public function addRootCategory()
{
$this->browser->find($this->header)->hover();
$this->_rootElement->find($this->addRootCategory, Locator::SELECTOR_CSS)->click();
$this->getTemplateBlock()->waitLoader();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class AssertCategoryForm extends AbstractAssertForm
* @var array
*/
protected $skippedFixtureFields = [
'parent_id'
'parent_id',
'id'
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,68 @@

namespace Magento\Catalog\Test\Constraint;

use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Catalog\Test\Fixture\Category;
use Magento\Cms\Test\Page\CmsIndex;
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
use Magento\Mtf\Client\BrowserInterface;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Class AssertCategoryIsNotActive
* Assert that the category cannot be accessed from the navigation bar in the frontend
* Assert that the category cannot be accessed using the direct URL and from the navigation bar in the frontend
*/
class AssertCategoryIsNotActive extends AbstractConstraint
{
const NOT_FOUND_MESSAGE = 'Whoops, our bad...';

/**
* Assert that the category cannot be accessed from the navigation bar in the frontend
* Assert that the category cannot be accessed using the direct URL and from the navigation bar in the frontend
*
* @param CmsIndex $cmsIndex
* @param Category $category
* @param CatalogCategoryView $categoryView
* @param BrowserInterface $browser
* @return void
*/
public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser)
{
$cmsIndex->open();
public function processAssert(
Category $category,
CatalogCategoryView $categoryView,
BrowserInterface $browser
) {
$browser->open($this->getCategoryUrl($category));
\PHPUnit_Framework_Assert::assertFalse(
$cmsIndex->getTopmenu()->isCategoryVisible($category->getName()),
$categoryView->getTopmenu()->isCategoryVisible($category->getName()),
'Category can be accessed from the navigation bar in the frontend.'
);
$browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
\PHPUnit_Framework_Assert::assertEquals(
self::NOT_FOUND_MESSAGE,
$cmsIndex->getTitleBlock()->getTitle(),
$categoryView->getTitleBlock()->getTitle(),
'Wrong page is displayed.'
);
}

/**
* Get category url to open.
*
* @param Category $category
* @return string
*/
protected function getCategoryUrl(Category $category)
{
$categoryUrlKey = [];
while ($category) {
$categoryUrlKey[] = $category->hasData('url_key')
? strtolower($category->getUrlKey())
: trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');

$category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
if (1 == $category->getParentId()) {
$category = null;
}
}

return $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html';
}


/**
* Category not find in top menu
*
Expand Down

This file was deleted.

Loading

0 comments on commit 5d5738a

Please sign in to comment.