Skip to content

Commit e67c38c

Browse files
Bohdan Korablovoshmyheliuk
authored andcommitted
MAGECLOUD-1121: [develop] In the file "app/etc/ env.php" settings "system" =>"default" =>"catalog"=>"search" does not exist after activation of ElasticSearch service (#52)
* MAGECLOUD-1121: [develop] In the file "app/etc/ env.php" settings "system" =>"default" =>"catalog"=>"search" does not exist after activation of ElasticSearch service * MAGECLOUD-1121: [develop] In the file "app/etc/ env.php" settings "system" =>"default" =>"catalog"=>"search" does not exist after activation of ElasticSearch service * MAGECLOUD-1121: [develop] In the file "app/etc/ env.php" settings "system" =>"default" =>"catalog"=>"search" does not exist after activation of ElasticSearch service
1 parent 5a759f1 commit e67c38c

File tree

5 files changed

+127
-15
lines changed

5 files changed

+127
-15
lines changed

src/App/Container.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function __construct(string $root, array $config)
108108
$this->make(DeployProcess\InstallUpdate\Install\Setup::class),
109109
$this->make(DeployProcess\InstallUpdate\Install\SecureAdmin::class),
110110
$this->make(DeployProcess\InstallUpdate\ConfigUpdate::class),
111+
$this->make(DeployProcess\InstallUpdate\Install\ConfigImport::class),
111112
$this->make(DeployProcess\InstallUpdate\Install\ResetPassword::class),
112113
],
113114
]);

src/Process/Deploy/InstallUpdate/ConfigUpdate/SearchEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public function execute()
6262
}
6363

6464
$this->logger->info('Set search engine to: ' . $searchConfig['engine']);
65-
66-
$this->writer->update($searchConfig);
65+
$config['system']['default']['catalog']['search'] = $searchConfig;
66+
$this->writer->update($config);
6767
}
6868

6969
/**
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\MagentoCloud\Process\Deploy\InstallUpdate\Install;
7+
8+
use Magento\MagentoCloud\Process\ProcessInterface;
9+
use Magento\MagentoCloud\Shell\ShellInterface;
10+
use Psr\Log\LoggerInterface;
11+
12+
/**
13+
* Imports configurations after changes env.php
14+
*
15+
* {@inheritdoc}
16+
*/
17+
class ConfigImport implements ProcessInterface
18+
{
19+
/**
20+
* @var ShellInterface
21+
*/
22+
private $shell;
23+
24+
/**
25+
* @var LoggerInterface
26+
*/
27+
private $logger;
28+
29+
/**
30+
* @param ShellInterface $shell
31+
* @param LoggerInterface $logger
32+
*/
33+
public function __construct(
34+
ShellInterface $shell,
35+
LoggerInterface $logger
36+
) {
37+
$this->shell = $shell;
38+
$this->logger = $logger;
39+
}
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
public function execute()
45+
{
46+
$this->logger->info('Run app:config:import command');
47+
$this->shell->execute('php ./bin/magento app:config:import -n');
48+
}
49+
}

src/Test/Unit/Process/Deploy/InstallUpdate/ConfigUpdate/SearchEngineTest.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ protected function setUp()
4949

5050
public function testExecute()
5151
{
52+
$config['system']['default']['catalog']['search'] = ['engine' => 'mysql'];
5253
$this->environmentMock->expects($this->once())
5354
->method('getRelationships')
5455
->willReturn([]);
5556
$this->writerMock->expects($this->once())
5657
->method('update')
57-
->with(['engine' => 'mysql']);
58+
->with($config);
5859
$this->loggerMock->expects($this->exactly(2))
5960
->method('info')
6061
->withConsecutive(
@@ -67,6 +68,12 @@ public function testExecute()
6768

6869
public function testExecuteWithElasticSearch()
6970
{
71+
$config['system']['default']['catalog']['search'] = [
72+
'engine' => 'elasticsearch',
73+
'elasticsearch_server_hostname' => 'localhost',
74+
'elasticsearch_server_port' => 1234
75+
];
76+
7077
$this->environmentMock->expects($this->once())
7178
->method('getRelationships')
7279
->willReturn(
@@ -81,11 +88,7 @@ public function testExecuteWithElasticSearch()
8188
);
8289
$this->writerMock->expects($this->once())
8390
->method('update')
84-
->with([
85-
'engine' => 'elasticsearch',
86-
'elasticsearch_server_hostname' => 'localhost',
87-
'elasticsearch_server_port' => 1234
88-
]);
91+
->with($config);
8992
$this->loggerMock->expects($this->exactly(2))
9093
->method('info')
9194
->withConsecutive(
@@ -98,6 +101,13 @@ public function testExecuteWithElasticSearch()
98101

99102
public function testExecuteWithElasticSolr()
100103
{
104+
$config['system']['default']['catalog']['search'] = [
105+
'engine' => 'solr',
106+
'solr_server_hostname' => 'localhost',
107+
'solr_server_port' => 1234,
108+
'solr_server_username' => 'scheme',
109+
'solr_server_path' => 'path'
110+
];
101111
$this->environmentMock->expects($this->once())
102112
->method('getRelationships')
103113
->willReturn(
@@ -114,13 +124,7 @@ public function testExecuteWithElasticSolr()
114124
);
115125
$this->writerMock->expects($this->once())
116126
->method('update')
117-
->with([
118-
'engine' => 'solr',
119-
'solr_server_hostname' => 'localhost',
120-
'solr_server_port' => 1234,
121-
'solr_server_username' => 'scheme',
122-
'solr_server_path' => 'path'
123-
]);
127+
->with($config);
124128
$this->loggerMock->expects($this->exactly(2))
125129
->method('info')
126130
->withConsecutive(
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\MagentoCloud\Test\Unit\Process\Deploy\InstallUpdate\Install;
7+
8+
use Magento\MagentoCloud\Process\Deploy\InstallUpdate\Install\ConfigImport;
9+
use PHPUnit\Framework\TestCase;
10+
use Magento\MagentoCloud\Shell\ShellInterface;
11+
use Psr\Log\LoggerInterface;
12+
use PHPUnit_Framework_MockObject_MockObject as Mock;
13+
14+
class ConfigImportTest extends TestCase
15+
{
16+
/**
17+
* @var ShellInterface|Mock
18+
*/
19+
private $shellMock;
20+
21+
/**
22+
* @var LoggerInterface|Mock
23+
*/
24+
private $loggerMock;
25+
26+
/**
27+
* @var ConfigImport
28+
*/
29+
private $configImport;
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
protected function setUp()
35+
{
36+
$this->shellMock = $this->getMockBuilder(ShellInterface::class)
37+
->getMockForAbstractClass();
38+
$this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
39+
->getMockForAbstractClass();
40+
41+
$this->configImport = new ConfigImport($this->shellMock, $this->loggerMock);
42+
}
43+
44+
/**
45+
* return void
46+
*/
47+
public function testExecute()
48+
{
49+
$this->loggerMock->expects($this->once())
50+
->method('info')
51+
->with('Run app:config:import command');
52+
$this->shellMock->expects($this->once())
53+
->method('execute')
54+
->with('php ./bin/magento app:config:import -n');
55+
56+
$this->configImport->execute();
57+
}
58+
}

0 commit comments

Comments
 (0)