Skip to content

Commit 07512eb

Browse files
committed
Merge remote-tracking branch 'origin/MC-19316' into 2.2.10-develop-pr112
2 parents 3e8c25b + 355917a commit 07512eb

File tree

4 files changed

+118
-15
lines changed

4 files changed

+118
-15
lines changed

app/code/Magento/Store/Model/ScopeTreeProvider.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,30 @@ public function get()
7979
'scopes' => [],
8080
];
8181

82-
/** @var Group $group */
83-
foreach ($groups[$website->getId()] as $group) {
84-
$groupScope = [
85-
'scope' => ScopeInterface::SCOPE_GROUP,
86-
'scope_id' => $group->getId(),
87-
'scopes' => [],
88-
];
89-
90-
/** @var Store $store */
91-
foreach ($stores[$group->getId()] as $store) {
92-
$storeScope = [
93-
'scope' => ScopeInterface::SCOPE_STORES,
94-
'scope_id' => $store->getId(),
82+
if (!empty($groups[$website->getId()])) {
83+
/** @var Group $group */
84+
foreach ($groups[$website->getId()] as $group) {
85+
$groupScope = [
86+
'scope' => ScopeInterface::SCOPE_GROUP,
87+
'scope_id' => $group->getId(),
9588
'scopes' => [],
9689
];
97-
$groupScope['scopes'][] = $storeScope;
90+
91+
if (!empty($stores[$group->getId()])) {
92+
/** @var Store $store */
93+
foreach ($stores[$group->getId()] as $store) {
94+
$storeScope = [
95+
'scope' => ScopeInterface::SCOPE_STORES,
96+
'scope_id' => $store->getId(),
97+
'scopes' => [],
98+
];
99+
$groupScope['scopes'][] = $storeScope;
100+
}
101+
}
102+
$websiteScope['scopes'][] = $groupScope;
98103
}
99-
$websiteScope['scopes'][] = $groupScope;
100104
}
105+
101106
$defaultScope['scopes'][] = $websiteScope;
102107
}
103108

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Indexer\Console\Command;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use PHPUnit_Framework_MockObject_MockObject as Mock;
13+
use Symfony\Component\Console\Input\InputInterface;
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
16+
/**
17+
* Tests for \Magento\Indexer\Console\Command\IndexerReindexCommand.
18+
*
19+
* @magentoDbIsolation disabled
20+
* @magentoAppIsolation enabled
21+
*/
22+
class IndexerReindexCommandTest extends \PHPUnit\Framework\TestCase
23+
{
24+
/**
25+
* @var ObjectManagerInterface
26+
*/
27+
private $objectManager;
28+
29+
/**
30+
* @var InputInterface|Mock
31+
*/
32+
private $inputMock;
33+
34+
/**
35+
* @var OutputInterface|Mock
36+
*/
37+
private $outputMock;
38+
39+
/**
40+
* @var IndexerReindexCommand
41+
*/
42+
private $command;
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
protected function setUp()
48+
{
49+
$this->objectManager = Bootstrap::getObjectManager();
50+
51+
$this->inputMock = $this->getMockBuilder(InputInterface::class)->getMockForAbstractClass();
52+
$this->outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
53+
54+
$this->command = $this->objectManager->get(IndexerReindexCommand::class);
55+
}
56+
57+
/**
58+
* @magentoDataFixture Magento/Store/_files/second_store_group_with_second_website.php
59+
*/
60+
public function testReindexAll()
61+
{
62+
$status = $this->command->run($this->inputMock, $this->outputMock);
63+
$this->assertEquals(
64+
\Magento\Framework\Console\Cli::RETURN_SUCCESS,
65+
$status,
66+
'Index wasn\'t success'
67+
);
68+
}
69+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
declare(strict_types=1);
8+
9+
require_once __DIR__ . '/website.php';
10+
11+
/**
12+
* @var \Magento\Store\Model\Group $storeGroup
13+
*/
14+
$storeGroup = $objectManager->create(\Magento\Store\Model\Group::class);
15+
$storeGroup->setCode('some_group')
16+
->setName('custom store group')
17+
->setWebsite($website);
18+
$storeGroup->save($storeGroup);
19+
20+
/* Refresh stores memory cache */
21+
$objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
require_once __DIR__ . '/website_rollback.php';

0 commit comments

Comments
 (0)