Skip to content

Commit fea31f8

Browse files
committed
Merge remote-tracking branch 'nord/MAGETWO-38738' into sprint-54-bf
2 parents 80cfc05 + 52b2639 commit fea31f8

File tree

4 files changed

+95
-11
lines changed

4 files changed

+95
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
* Fixed an issue where first store could not be selected on frontend
113113
* Fixed an issue with performance toolkit category creation
114114
* Fixed an issue when columns 'Interval', 'Price Rule' had incorrect values in Coupon Usage report
115-
* Fixed an issue where fatal error occured on Abandoned Carts report grid
115+
* Fixed an issue where fatal error occurred on Abandoned Carts report grid
116116
* Fixed an issue where it was not possible to add product to shopping cart if Use Secure URLs in Frontend = Yes
117117
* Fixed an issue where email was not required during Guest Checkout
118118
* Fixed broken ability to skip reindex in `bin/magento setup:performance:generate-fixtures` command
@@ -2699,7 +2699,7 @@
26992699
* Fixed an issue with status and visibility settings of a related product on the backend
27002700
* Fixed an issue with unused DB indexes, which used resources, but did not contribute to higher performance
27012701
* Fixed an issue where it was possible to create a downloadable product without specifying a link or a file
2702-
* Fixed an issue where a fatal error occured when opening a fixed bundle product with custom options page on the frontend
2702+
* Fixed an issue where a fatal error occurred when opening a fixed bundle product with custom options page on the frontend
27032703
* Fixed an issue where the was a wrong config key for backend cataloginventory
27042704
* Processed GitHub requests:
27052705
* [#548] (https://github.com/magento/magento2/issues/548) -- Console installer doesn't checks filesystem permissions

app/code/Magento/Catalog/Block/Navigation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ public function getCacheKeyInfo()
145145
$this->httpContext->getValue(Context::CONTEXT_GROUP),
146146
'template' => $this->getTemplate(),
147147
'name' => $this->getNameInLayout(),
148-
$this->getCurrenCategoryKey(),
148+
$this->getCurrentCategoryKey(),
149149
];
150150
$cacheId = $shortCacheId;
151151

152152
$shortCacheId = array_values($shortCacheId);
153153
$shortCacheId = implode('|', $shortCacheId);
154154
$shortCacheId = md5($shortCacheId);
155155

156-
$cacheId['category_path'] = $this->getCurrenCategoryKey();
156+
$cacheId['category_path'] = $this->getCurrentCategoryKey();
157157
$cacheId['short_cache_id'] = $shortCacheId;
158158

159159
return $cacheId;
@@ -164,7 +164,7 @@ public function getCacheKeyInfo()
164164
*
165165
* @return string
166166
*/
167-
public function getCurrenCategoryKey()
167+
public function getCurrentCategoryKey()
168168
{
169169
if (!$this->_currentCategoryKey) {
170170
$category = $this->_registry->registry('current_category');

app/code/Magento/Catalog/Test/Unit/Block/NavigationTest.php

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ class NavigationTest extends \PHPUnit_Framework_TestCase
1212
*/
1313
protected $block;
1414

15+
/**
16+
* @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
protected $registry;
19+
20+
/**
21+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
protected $storeManager;
24+
25+
/**
26+
* @var \Magento\Framework\View\DesignInterface|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
protected $design;
29+
30+
/**
31+
* @var \Magento\Framework\App\Http\Context|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
protected $httpContext;
34+
1535
protected function setUp()
1636
{
1737
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -22,22 +42,85 @@ protected function setUp()
2242
'',
2343
false
2444
);
45+
$this->registry = $this->getMock('Magento\Framework\Registry');
46+
$this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface');
47+
$this->design = $this->getMock('Magento\Framework\View\DesignInterface');
48+
$this->httpContext = $this->getMock('Magento\Framework\App\Http\Context', [], [], '', false);
2549
$this->block = $objectManager->getObject(
2650
'Magento\Catalog\Block\Navigation',
27-
['categoryFactory' => $categoryFactory]
51+
[
52+
'categoryFactory' => $categoryFactory,
53+
'registry' => $this->registry,
54+
'storeManager' => $this->storeManager,
55+
'design' => $this->design,
56+
'httpContext' => $this->httpContext
57+
]
2858
);
2959
}
3060

31-
protected function tearDown()
32-
{
33-
$this->block = null;
34-
}
35-
3661
public function testGetIdentities()
3762
{
3863
$this->assertEquals(
3964
[\Magento\Catalog\Model\Category::CACHE_TAG, \Magento\Store\Model\Group::CACHE_TAG],
4065
$this->block->getIdentities()
4166
);
4267
}
68+
69+
public function testGetCurrentCategoryKey()
70+
{
71+
$categoryKey = 101;
72+
$category = $this->getMock('Magento\Catalog\Model\Category', [], [], '', false);
73+
$category->expects($this->any())->method('getPath')->willReturn($categoryKey);
74+
75+
$this->registry->expects($this->any())->method('registry')->with('current_category')->willReturn($category);
76+
77+
$this->assertEquals($categoryKey, $this->block->getCurrentCategoryKey());
78+
}
79+
80+
public function testGetCurrentCategoryKeyFromRootCategory()
81+
{
82+
$categoryKey = 102;
83+
$store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
84+
$store->expects($this->any())->method('getRootCategoryId')->willReturn($categoryKey);
85+
86+
$this->storeManager->expects($this->any())->method('getStore')->willReturn($store);
87+
88+
$this->assertEquals($categoryKey, $this->block->getCurrentCategoryKey());
89+
}
90+
91+
public function testGetCacheKeyInfo()
92+
{
93+
$store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
94+
$store->expects($this->atLeastOnce())->method('getId')->willReturn(55);
95+
$store->expects($this->atLeastOnce())->method('getRootCategoryId')->willReturn(60);
96+
97+
$this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
98+
99+
$theme = $this->getMock('\Magento\Framework\View\Design\ThemeInterface');
100+
$theme->expects($this->atLeastOnce())->method('getId')->willReturn(65);
101+
102+
$this->design->expects($this->atLeastOnce())->method('getDesignTheme')->willReturn($theme);
103+
104+
$this->httpContext->expects($this->atLeastOnce())
105+
->method('getValue')
106+
->with(\Magento\Customer\Model\Context::CONTEXT_GROUP)
107+
->willReturn(70);
108+
109+
$this->block->setTemplate('block_template');
110+
$this->block->setNameInLayout('block_name');
111+
112+
$expectedResult = [
113+
'CATALOG_NAVIGATION',
114+
55,
115+
65,
116+
70,
117+
'template' => 'block_template',
118+
'name' => 'block_name',
119+
60,
120+
'category_path' => 60,
121+
'short_cache_id' => 'c3de6d1160d1e7730b04d6cad409a2b4'
122+
];
123+
124+
$this->assertEquals($expectedResult, $this->block->getCacheKeyInfo());
125+
}
43126
}

dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,4 +2245,5 @@
22452245
['getOrigData', 'Magento\Framework\Object', 'Moved to Magento\Framework\Model\AbstractModel'],
22462246
['dataHasChangedFor', 'Magento\Framework\Object', 'Moved to Magento\Framework\Model\AbstractModel'],
22472247
['setDataChanges', 'Magento\Framework\Object', 'Moved to Magento\Framework\Model\AbstractModel'],
2248+
['getCurrenCategoryKey', 'Magento\Catalog\Block\Navigation', 'getCurrentCategoryKey'],
22482249
];

0 commit comments

Comments
 (0)