Skip to content

Commit 5271f43

Browse files
author
OlgaVasyltsun
committed
MC-19334: Reindex error when website have store without store view
1 parent 6bea102 commit 5271f43

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
*/
21+
class IndexerReindexCommandTest extends \PHPUnit\Framework\TestCase
22+
{
23+
/**
24+
* @var ObjectManagerInterface
25+
*/
26+
private $objectManager;
27+
28+
/**
29+
* @var InputInterface|Mock
30+
*/
31+
private $inputMock;
32+
33+
/**
34+
* @var OutputInterface|Mock
35+
*/
36+
private $outputMock;
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
protected function setUp()
42+
{
43+
Bootstrap::getInstance()->reinitialize();
44+
$this->objectManager = Bootstrap::getObjectManager();
45+
46+
$this->inputMock = $this->getMockBuilder(InputInterface::class)
47+
->getMockForAbstractClass();
48+
$this->outputMock = $this->getMockBuilder(OutputInterface::class)
49+
->getMockForAbstractClass();
50+
}
51+
52+
/**
53+
* @magentoDataFixture Magento/Store/_files/second_store_group_with_second_website.php
54+
*/
55+
public function testReindexAll()
56+
{
57+
$command = $this->objectManager->create(IndexerReindexCommand::class);
58+
$status = $command->run($this->inputMock, $this->outputMock);
59+
$this->assertEquals(0, $status, 'Index wasn\'t success');
60+
}
61+
}
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 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->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)