Skip to content

Commit 355917a

Browse files
author
OlgaVasyltsun
committed
MC-19316: Reindex error when website have store without store view
1 parent 298e4f7 commit 355917a

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed
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)