Skip to content

Commit 3f3f02c

Browse files
author
Yaroslav Onischenko
committed
MAGETWO-57812: [BACKPORT 2.1.2] It is possible to delete self admin account or role
2 parents 13ef833 + 9af69bf commit 3f3f02c

File tree

6 files changed

+68
-12
lines changed

6 files changed

+68
-12
lines changed

app/code/Magento/Backend/Block/Store/Switcher.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
/**
1010
* Store switcher block
11-
*
12-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1311
*/
1412
class Switcher extends \Magento\Backend\Block\Template
1513
{
@@ -152,11 +150,7 @@ public function getWebsites()
152150
{
153151
$websites = $this->_storeManager->getWebsites();
154152
if ($websiteIds = $this->getWebsiteIds()) {
155-
foreach (array_keys($websites) as $websiteId) {
156-
if (!in_array($websiteId, $websiteIds)) {
157-
unset($websites[$websiteId]);
158-
}
159-
}
153+
$websites = array_intersect_key($websites, array_flip($websiteIds));
160154
}
161155
return $websites;
162156
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Unit\Block\Store;
8+
9+
class SwitcherTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \Magento\Backend\Block\Store\Switcher
13+
*/
14+
private $switcherBlock;
15+
16+
private $storeManagerMock;
17+
18+
protected function setUp()
19+
{
20+
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
21+
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
22+
$context = $objectHelper->getObject(
23+
\Magento\Backend\Block\Template\Context::class,
24+
[
25+
'storeManager' => $this->storeManagerMock,
26+
]
27+
);
28+
29+
$this->switcherBlock = $objectHelper->getObject(
30+
\Magento\Backend\Block\Store\Switcher::class,
31+
['context' => $context]
32+
);
33+
}
34+
35+
public function testGetWebsites()
36+
{
37+
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
38+
$websites = [0 => $websiteMock, 1 => $websiteMock];
39+
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
40+
$this->assertEquals($websites, $this->switcherBlock->getWebsites());
41+
}
42+
43+
public function testGetWebsitesIfSetWebsiteIds()
44+
{
45+
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
46+
$websites = [0 => $websiteMock, 1 => $websiteMock];
47+
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
48+
49+
$this->switcherBlock->setWebsiteIds([1]);
50+
$expected = [1 => $websiteMock];
51+
$this->assertEquals($expected, $this->switcherBlock->getWebsites());
52+
}
53+
}

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ private function processRangeNumeric(FilterInterface $filter, $query, $attribute
179179
$tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : '';
180180
$table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}");
181181
$select = $this->connection->select();
182-
$linkIdField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
182+
$entityField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getIdentifierField();
183183

184184
$currentStoreId = $this->scopeResolver->getScope()->getId();
185185

186186
$select->from(['e' => $this->resource->getTableName('catalog_product_entity')], ['entity_id'])
187187
->join(
188188
['main_table' => $table],
189-
"main_table.{$linkIdField} = e.{$linkIdField}",
189+
"main_table.{$entityField} = e.{$entityField}",
190190
[]
191191
)
192192
->columns([$filter->getField() => 'main_table.value'])

app/code/Magento/Sales/view/frontend/templates/order/history.phtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
<span><?php /* @escapeNotVerified */ echo __('View Order') ?></span>
4343
</a>
4444
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
45-
<a href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>" class="action order">
45+
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
46+
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
47+
->getPostData($block->getReorderUrl($_order))
48+
?>' class="action order">
4649
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
4750
</a>
4851
<?php endif ?>

app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
<div class="actions">
1111
<?php $_order = $block->getOrder() ?>
1212
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
13-
<a class="action reorder" href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>">
13+
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
14+
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
15+
->getPostData($block->getReorderUrl($_order))
16+
?>' class="action order">
1417
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
1518
</a>
1619
<?php endif ?>

app/code/Magento/Sales/view/frontend/templates/order/recent.phtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
<span><?php /* @escapeNotVerified */ echo __('View Order') ?></span>
4747
</a>
4848
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
49-
<a href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>" class="action order">
49+
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
50+
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
51+
->getPostData($block->getReorderUrl($_order))
52+
?>' class="action order">
5053
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
5154
</a>
5255
<?php endif ?>

0 commit comments

Comments
 (0)