Skip to content

Commit 35951f8

Browse files
committed
MAGETWO-63209: Fatal error on category page when changing display mode with flat category on
1 parent c252ae1 commit 35951f8

File tree

17 files changed

+144
-22
lines changed

17 files changed

+144
-22
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Category/Collection/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2017 Magento. All rights reserved.
3+
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento\Catalog\Model\ResourceModel\Category\Collection;

app/code/Magento/Catalog/Model/ResourceModel/Category/Flat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2017 Magento. All rights reserved.
3+
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento\Catalog\Model\ResourceModel\Category;

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Category/FlatTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2017 Magento. All rights reserved.
3+
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ class CategoryForm extends FormTabs
3737
*/
3838
protected $confirmModal = '.confirm._show[data-role=modal]';
3939

40+
/**
41+
* Category edit title.
42+
*
43+
* @var string
44+
*/
45+
protected $categoryTitle = '.category-edit-title h3.title';
46+
4047
/**
4148
* Fill form with tabs.
4249
*
@@ -59,4 +66,25 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
5966

6067
return $this->fillTabs($tabs, $element);
6168
}
69+
70+
/**
71+
* Return category Id.
72+
*
73+
* @return string
74+
*/
75+
public function getCategoryId()
76+
{
77+
$titleElement = $this->_rootElement->find($this->categoryTitle);
78+
$title = '';
79+
if ($titleElement->isVisible()) {
80+
$title = $titleElement->getText();
81+
}
82+
83+
$categoryId = '';
84+
if (preg_match('/ID:\s*(?<id>\d+)/', $title, $matches)) {
85+
$categoryId = $matches['id'];
86+
}
87+
88+
return $categoryId;
89+
}
6290
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" ?>
22
<!--
33
/**
4-
* Copyright © 2017 Magento. All rights reserved.
4+
* Copyright © 2016 Magento. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
77
-->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2017 Magento. All rights reserved.
3+
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2017 Magento. All rights reserved.
3+
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
1212
use Magento\Mtf\Client\BrowserInterface;
1313
use Magento\Mtf\Constraint\AbstractConstraint;
14+
use Magento\Mtf\Fixture\FixtureFactory;
1415

1516
/**
1617
* Assert that displayed category data on category page equals to passed from fixture.
@@ -45,23 +46,49 @@ class AssertCategoryPage extends AbstractConstraint
4546
* Assert that displayed category data on category page equals to passed from fixture.
4647
*
4748
* @param Category $category
49+
* @param FixtureFactory $fixtureFactory
4850
* @param CatalogCategoryView $categoryView
4951
* @param BrowserInterface $browser
5052
* @return void
5153
*/
5254
public function processAssert(
5355
Category $category,
56+
FixtureFactory $fixtureFactory,
5457
CatalogCategoryView $categoryView,
5558
BrowserInterface $browser
5659
) {
5760
$this->browser = $browser;
5861
$this->categoryViewPage = $categoryView;
62+
$this->prepareData($fixtureFactory, $category);
5963
$this->browser->open($this->getCategoryUrl($category));
6064

6165
$this->assertGeneralInformation($category);
6266
$this->assertDisplaySetting($category);
6367
}
6468

69+
/**
70+
* Prepare comparison data.
71+
*
72+
* @param FixtureFactory $fixtureFactory
73+
* @param Category $category
74+
* @return void
75+
*/
76+
protected function prepareData(FixtureFactory $fixtureFactory, Category $category)
77+
{
78+
$product = $fixtureFactory->createByCode(
79+
'catalogProductSimple',
80+
[
81+
'dataset' => 'default',
82+
'data' => [
83+
'category_ids' => [
84+
'category' => $category,
85+
],
86+
]
87+
]
88+
);
89+
$product->persist();
90+
}
91+
6592
/**
6693
* Get category url to open.
6794
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
33
/**
4-
* Copyright © 2017 Magento. All rights reserved.
4+
* Copyright © 2016 Magento. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
77
-->

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/CategoryProducts.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public function __construct(FixtureFactory $fixtureFactory, array $params, $data
4141
$this->data[] = $product->getName();
4242
$this->products[] = $product;
4343
}
44+
} else if (isset($data['products']) && is_array($data['products'])) {
45+
foreach ($data['products'] as $product) {
46+
$this->data[] = $product->getName();
47+
$this->products[] = $product;
48+
}
4449
}
4550
}
4651

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/LandingPage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2017 Magento. All rights reserved.
3+
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

0 commit comments

Comments
 (0)