Skip to content

Commit a199d79

Browse files
committed
Update defaults and version validation test
1 parent c603d7c commit a199d79

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/Config/Validator/Deploy/AppropriateVersion.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,20 @@ public function validate(): Validator\ResultInterface
8181
);
8282
}
8383

84-
if (!$this->magentoVersion->satisfies('>= 2.4.7')
85-
&& $this->configurationChecker->isConfigured(DeployInterface::VAR_USE_LUA, true)
86-
) {
87-
$errors[] = sprintf(
88-
'%s is available for Magento 2.4.7 and above',
89-
DeployInterface::VAR_USE_LUA
90-
);
91-
}
84+
if (!$this->magentoVersion->satisfies('>= 2.4.7')) {
85+
$variables = [
86+
DeployInterface::VAR_USE_LUA,
87+
DeployInterface::VAR_LUA_KEY,
88+
];
9289

93-
if (!$this->magentoVersion->satisfies('>= 2.4.7')
94-
&& $this->configurationChecker->isConfigured(DeployInterface::VAR_LUA_KEY, true)
95-
) {
96-
$errors[] = sprintf(
97-
'%s is available for Magento 2.4.7 and above',
98-
DeployInterface::VAR_LUA_KEY
99-
);
90+
foreach ($variables as $variableName) {
91+
if ($this->configurationChecker->isConfigured($variableName, true)) {
92+
$errors[] = sprintf(
93+
'%s is available for Magento 2.4.7 and later.',
94+
$variableName
95+
);
96+
}
97+
}
10098
}
10199

102100
if ($errors) {

src/Test/Unit/Config/SchemaTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public function testGetDefaultsForDeploy(): void
118118
DeployInterface::VAR_CACHE_REDIS_BACKEND => 'Cm_Cache_Backend_Redis',
119119
DeployInterface::VAR_REMOTE_STORAGE => [],
120120
DeployInterface::VAR_SCD_NO_PARENT => false,
121+
DeployInterface::VAR_USE_LUA => false,
122+
DeployInterface::VAR_LUA_KEY => true,
121123
],
122124
$this->schema->getDefaults(StageConfigInterface::STAGE_DEPLOY)
123125
);

src/Test/Unit/Step/Deploy/PreDeploy/ConfigUpdate/CacheTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use PHPUnit\Framework\TestCase;
2020
use Psr\Log\LoggerInterface;
2121
use Magento\MagentoCloud\Package\MagentoVersion;
22+
use Magento\MagentoCloud\Config\Stage\DeployInterface;
2223

2324
/**
2425
* @inheritdoc
@@ -72,6 +73,11 @@ class CacheTest extends TestCase
7273
*/
7374
private $magentoVersion;
7475

76+
/**
77+
* @var DeployInterface
78+
*/
79+
private $stageConfig;
80+
7581
/**
7682
* @inheritdoc
7783
*/
@@ -82,13 +88,15 @@ protected function setUp(): void
8288
$this->configReaderMock = $this->createMock(ConfigReader::class);
8389
$this->cacheConfigMock = $this->createMock(CacheFactory::class);
8490
$this->magentoVersion = $this->createMock(MagentoVersion::class);
91+
$this->stageConfig = $this->createMock(DeployInterface::class);
8592

8693
$this->step = new Cache(
8794
$this->configReaderMock,
8895
$this->configWriterMock,
8996
$this->loggerMock,
9097
$this->cacheConfigMock,
91-
$this->magentoVersion
98+
$this->magentoVersion,
99+
$this->stageConfig
92100
);
93101

94102
$this->socketCreateMock = $this->getFunctionMock(

0 commit comments

Comments
 (0)