Skip to content

Commit 9f46b4e

Browse files
author
Bohdan Korablov
committed
MAGETWO-64602: Sync config file with DB: Validation
1 parent e204b84 commit 9f46b4e

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function regenerate()
7979
$config = $this->dataConfigCollector->getConfig();
8080
$hash = $this->configHashGenerator->generate($config);
8181
$this->writer->saveConfig([ConfigFilePool::APP_ENV => [self::CONFIG_KEY => $hash]]);
82-
} catch (LocalizedException $exception) {
82+
} catch (FileSystemException $exception) {
8383
throw new LocalizedException(__('Hash has not been saved'), $exception);
8484
}
8585
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Test\Unit\Model\DeploymentConfig;
7+
8+
use Magento\Deploy\Model\DeploymentConfig\DataCollector;
9+
use Magento\Deploy\Model\DeploymentConfig\ImporterPool;
10+
use Magento\Framework\App\DeploymentConfig;
11+
12+
class DataCollectorTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* @var ImporterPool|\PHPUnit_Framework_MockObject_MockObject
16+
*/
17+
private $configImporterPoolMock;
18+
19+
/**
20+
* @var DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
private $deploymentConfigMock;
23+
24+
/**
25+
* @var DataCollector
26+
*/
27+
private $dataCollector;
28+
29+
/**
30+
* @return void
31+
*/
32+
protected function setUp()
33+
{
34+
$this->configImporterPoolMock = $this->getMockBuilder(ImporterPool::class)
35+
->disableOriginalConstructor()
36+
->getMock();
37+
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
38+
->disableOriginalConstructor()
39+
->getMock();
40+
41+
$this->dataCollector = new DataCollector($this->configImporterPoolMock, $this->deploymentConfigMock);
42+
}
43+
44+
public function testGetConfig()
45+
{
46+
$sections = ['first', 'second'];
47+
$this->configImporterPoolMock->expects($this->once())
48+
->method('getSections')
49+
->willReturn($sections);
50+
$this->deploymentConfigMock->expects($this->any())
51+
->method('getConfigData')
52+
->willReturnMap([['first', 'some data']]);
53+
54+
$this->assertSame(['first' => 'some data'], $this->dataCollector->getConfig());
55+
}
56+
}

dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Magento\Framework\Filesystem;
17-
use Magento\Framework\App\DeploymentConfig\ConfigHashManager;
17+
use Magento\Deploy\Model\DeploymentConfig\Hash;
1818

1919
/**
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -62,7 +62,7 @@ public function setUp()
6262
*/
6363
public function testExecute()
6464
{
65-
$this->assertArrayNotHasKey(ConfigHashManager::CONFIG_KEY, $this->contentEnvFile);
65+
$this->assertArrayNotHasKey(Hash::CONFIG_KEY, $this->contentEnvFile);
6666
$this->objectManager->configure([
6767
\Magento\Config\Model\Config\Export\ExcludeList::class => [
6868
'arguments' => [
@@ -94,7 +94,7 @@ public function testExecute()
9494

9595
$this->validateSystemSection($config);
9696
$this->validateThemesSection($config);
97-
$this->assertArrayHasKey(ConfigHashManager::CONFIG_KEY, $this->getEnvFileContent());
97+
$this->assertArrayHasKey(Hash::CONFIG_KEY, $this->getEnvFileContent());
9898
}
9999

100100
/**

0 commit comments

Comments
 (0)