Skip to content

Commit 9177024

Browse files
committed
update unit tests
1 parent 0ee0ff8 commit 9177024

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

src/Step/Deploy/PreDeploy/ConfigUpdate/Cache.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ public function execute()
123123
);
124124
unset($config['cache']);
125125
} else {
126+
if(isset($cacheConfig['frontend']['default'])) {
127+
$cacheConfig['frontend']['default']['backend_options']['_useLua'] = $luaConfigKey;
128+
$cacheConfig['frontend']['default']['backend_options']['use_lua'] = $luaConfig;
129+
}
126130
$this->logger->info('Updating cache configuration.');
127131
$config['cache'] = $cacheConfig;
128132
}
@@ -131,13 +135,6 @@ public function execute()
131135
$config['cache']['graphql'] = $graphqlConfig;
132136
}
133137

134-
if (!empty($luaConfigKey)) {
135-
$config['cache']['frontend']['default']['backend_options']['_useLua'] = $luaConfigKey;
136-
}
137-
138-
if (!empty($luaConfig)) {
139-
$config['cache']['frontend']['default']['backend_options']['use_lua'] = $luaConfig;
140-
}
141138
$this->configWriter->create($config);
142139
} catch (FileSystemException $e) {
143140
throw new StepException($e->getMessage(), Error::DEPLOY_ENV_PHP_IS_NOT_WRITABLE);

src/Test/Unit/Config/Validator/Deploy/AppropriateVersionTest.php

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\MagentoCloud\Package\MagentoVersion;
1616
use PHPUnit\Framework\MockObject\MockObject;
1717
use PHPUnit\Framework\TestCase;
18+
use Magento\MagentoCloud\Config\Stage\DeployInterface;
1819

1920
/**
2021
* @inheritdoc
@@ -60,16 +61,12 @@ protected function setUp(): void
6061
);
6162
}
6263

63-
public function testValidateVersionGreaterTwoDotTwo()
64+
public function testValidateVersion()
6465
{
65-
$this->magentoVersion->expects($this->once())
66-
->method('isGreaterOrEqual')
67-
->with('2.2')
68-
->willReturn(true);
69-
$this->magentoVersion->expects($this->once())
66+
$this->magentoVersion->expects($this->exactly(2))
7067
->method('isGreaterOrEqual')
71-
->with('2.4.7')
72-
->willReturn(true);
68+
->withConsecutive(['2.2'], ['2.4.7'])
69+
->willReturnOnConsecutiveCalls(true, true);
7370
$this->magentoVersion->expects($this->once())
7471
->method('satisfies')
7572
->willReturn(true);
@@ -79,40 +76,32 @@ public function testValidateVersionGreaterTwoDotTwo()
7976
$this->assertInstanceOf(Success::class, $this->validator->validate());
8077
}
8178

82-
public function testValidateVersionTwoDotOneAndVariablesNotConfigured()
79+
public function testValidateVersionAndVariablesNotConfigured()
8380
{
84-
$this->magentoVersion->expects($this->once())
81+
$this->magentoVersion->expects($this->exactly(2))
8582
->method('isGreaterOrEqual')
86-
->with('2.2')
87-
->willReturn(false);
88-
$this->magentoVersion->expects($this->once())
89-
->method('isGreaterOrEqual')
90-
->with('2.4.7')
91-
->willReturn(false);
83+
->withConsecutive(['2.2'], ['2.4.7'])
84+
->willReturnOnConsecutiveCalls(false, false);
9285
$this->magentoVersion->expects($this->once())
9386
->method('satisfies')
9487
->willReturn(false);
95-
$this->configurationCheckerMock->expects($this->exactly(4))
88+
$this->configurationCheckerMock->expects($this->exactly(6))
9689
->method('isConfigured')
9790
->willReturn(false);
9891

9992
$this->assertInstanceOf(Success::class, $this->validator->validate());
10093
}
10194

102-
public function testValidateVersionTwoDotOneAndAllVariablesAreConfigured()
95+
public function testValidateVersionAndAllVariablesAreConfigured()
10396
{
104-
$this->magentoVersion->expects($this->once())
97+
$this->magentoVersion->expects($this->exactly(2))
10598
->method('isGreaterOrEqual')
106-
->with('2.2')
107-
->willReturn(false);
108-
$this->magentoVersion->expects($this->once())
109-
->method('isGreaterOrEqual')
110-
->with('2.4.7')
111-
->willReturn(false);
99+
->withConsecutive(['2.2'], ['2.4.7'])
100+
->willReturnOnConsecutiveCalls(false, false);
112101
$this->magentoVersion->expects($this->once())
113102
->method('satisfies')
114103
->willReturn(false);
115-
$this->configurationCheckerMock->expects($this->exactly(4))
104+
$this->configurationCheckerMock->expects($this->exactly(6))
116105
->method('isConfigured')
117106
->willReturn(true);
118107
$this->resultFactoryMock->expects($this->once())
@@ -123,7 +112,9 @@ public function testValidateVersionTwoDotOneAndAllVariablesAreConfigured()
123112
'CRON_CONSUMERS_RUNNER is available for Magento 2.2.0 and later.',
124113
'SCD_STRATEGY is available for Magento 2.2.0 and later.',
125114
'SCD_MAX_EXECUTION_TIME is available for Magento 2.2.0 and later.',
126-
'GENERATED_CODE_SYMLINK is available for Magento 2.1.x.'
115+
'GENERATED_CODE_SYMLINK is available for Magento 2.1.x.',
116+
'USE_LUA is available for Magento 2.4.7 and later.',
117+
'LUA_KEY is available for Magento 2.4.7 and later.'
127118
])
128119
);
129120

0 commit comments

Comments
 (0)