Skip to content

Commit 4ecd822

Browse files
authored
MCLOUD-6327: REDIS_BACKEND should work with Magento since 2.3.0 (magento#751)
1 parent ee47ac5 commit 4ecd822

File tree

10 files changed

+372
-52
lines changed

10 files changed

+372
-52
lines changed

codeception.dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ modules:
2424
composer_magento_username: "%REPO_USERNAME%"
2525
composer_magento_password: "%REPO_PASSWORD%"
2626
composer_github_token: "%GITHUB_TOKEN%"
27-
printOutput: false
27+
printOutput: true
2828
Magento\CloudDocker\Test\Functional\Codeception\Docker:
2929
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
30-
printOutput: false
30+
printOutput: true
3131
PhpBrowser:
3232
url: "%Magento.docker.settings.env.url.base%"
3333
Magento\CloudDocker\Test\Functional\Codeception\MagentoDb:

src/Config/Factory/Cache.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private function isConfigurationCompatibleWithSlaveConnection(
254254
private function getUnsyncedConfigStructure(string $envCacheBackendModel, array $redisConfig): array
255255
{
256256
return [
257-
'backend' => addslashes($envCacheBackendModel),
257+
'backend' => $envCacheBackendModel,
258258
'backend_options' => [
259259
'server' => $redisConfig['host'],
260260
'port' => $redisConfig['port'],
@@ -272,9 +272,9 @@ private function getUnsyncedConfigStructure(string $envCacheBackendModel, array
272272
private function getSynchronizedConfigStructure(string $envCacheBackendModel, array $redisConfig): array
273273
{
274274
return [
275-
'backend' => addslashes($envCacheBackendModel),
275+
'backend' => $envCacheBackendModel,
276276
'backend_options' => [
277-
'remote_backend' => addslashes('\Magento\Framework\Cache\Backend\Redis'),
277+
'remote_backend' => '\Magento\Framework\Cache\Backend\Redis',
278278
'remote_backend_options' => [
279279
'server' => $redisConfig['host'],
280280
'port' => $redisConfig['port'],

src/Step/Deploy/PreDeploy/CleanRedisCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function execute(): void
6464
}
6565

6666
foreach ($cacheConfigs['frontend'] as $cacheType => $cacheConfig) {
67-
$backend = stripslashes($cacheConfig['backend']);
67+
$backend = $cacheConfig['backend'];
6868

6969
if (!in_array($backend, CacheConfig::AVAILABLE_REDIS_BACKEND, true)) {
7070
continue;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function execute()
7979

8080
if (isset($cacheConfig['frontend'])) {
8181
$cacheConfig['frontend'] = array_filter($cacheConfig['frontend'], function ($cacheFrontend) {
82-
$backend = stripslashes($cacheFrontend['backend']);
82+
$backend = $cacheFrontend['backend'];
8383
$this->checkBackendModel($backend);
8484

8585
if (!in_array($backend, CacheFactory::AVAILABLE_REDIS_BACKEND, true)) {
@@ -128,7 +128,7 @@ private function checkBackendModel(string $backend): void
128128
];
129129

130130
try {
131-
if (in_array($backend, $notAllowedBackend, true) && !$this->magentoVersion->isGreaterOrEqual('2.3.5')) {
131+
if (in_array($backend, $notAllowedBackend, true) && !$this->magentoVersion->isGreaterOrEqual('2.3.0')) {
132132
throw new StepException(
133133
sprintf(
134134
'Magento version \'%s\' does not support Redis backend model \'%s\'',

src/Test/Functional/Acceptance/RedisCest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function defaultConfigurationDataProvider(): array
109109
* @param \CliTester $I
110110
* @param \Codeception\Example $data
111111
* @throws \Robo\Exception\TaskException
112-
* @dataProvider wrongConfigurationData
112+
* @dataProvider wrongConfigurationDataProvider
113113
*/
114114
public function testWrongConfiguration(\CliTester $I, \Codeception\Example $data): void
115115
{
@@ -131,7 +131,7 @@ public function testWrongConfiguration(\CliTester $I, \Codeception\Example $data
131131
/**
132132
* @return array
133133
*/
134-
protected function wrongConfigurationData(): array
134+
protected function wrongConfigurationDataProvider(): array
135135
{
136136
return [
137137
[
@@ -208,7 +208,7 @@ protected function goodConfigurationDataProvider(): array
208208
],
209209
],
210210
],
211-
'expectedBackend' => '\\\Magento\\\Framework\\\Cache\\\Backend\\\Redis',
211+
'expectedBackend' => '\Magento\Framework\Cache\Backend\Redis',
212212
'expectedConfig' => [
213213
'backend_options' => [
214214
'server' => 'redis',
@@ -226,10 +226,10 @@ protected function goodConfigurationDataProvider(): array
226226
],
227227
],
228228
],
229-
'expectedBackend' => '\\\Magento\\\Framework\\\Cache\\\Backend\\\RemoteSynchronizedCache',
229+
'expectedBackend' => '\Magento\Framework\Cache\Backend\RemoteSynchronizedCache',
230230
'expectedConfig' => [
231231
'backend_options' => [
232-
'remote_backend' => '\\\Magento\\\Framework\\\Cache\\\Backend\\\Redis',
232+
'remote_backend' => '\Magento\Framework\Cache\Backend\Redis',
233233
'remote_backend_options' => [
234234
'persistent' => 0,
235235
'server' => 'redis',
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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\MagentoCloud\Test\Functional\Acceptance;
9+
10+
/**
11+
* @group php71
12+
*/
13+
class RedisPhp71Cest extends RedisCest
14+
{
15+
/**
16+
* @return array
17+
*/
18+
protected function defaultConfigurationDataProvider(): array
19+
{
20+
return [
21+
[
22+
'version' => '2.2.11',
23+
],
24+
];
25+
}
26+
27+
/**
28+
* @return array
29+
*/
30+
protected function wrongConfigurationDataProvider(): array
31+
{
32+
return [
33+
[
34+
'version' => '2.2.11',
35+
'wrongConfiguration' => [
36+
'stage' => [
37+
'deploy' => [
38+
'REDIS_BACKEND' => '\Magento\Framework\Cache\Backend\Redis'
39+
]
40+
]
41+
],
42+
'buildSuccess' => true,
43+
'deploySuccess' => false,
44+
'errorBuildMessage' => '',
45+
'errorDeployMessage' => 'does not support Redis backend model '
46+
. '\'\Magento\Framework\Cache\Backend\Redis\'',
47+
],
48+
[
49+
'version' => '2.2.11',
50+
'wrongConfiguration' => [
51+
'stage' => [
52+
'deploy' => [
53+
'REDIS_BACKEND' => '\Magento\Framework\Cache\Backend\RemoteSynchronizedCache'
54+
]
55+
]
56+
],
57+
'buildSuccess' => true,
58+
'deploySuccess' => false,
59+
'errorBuildMessage' => '',
60+
'errorDeployMessage' => 'does not support Redis backend model '
61+
. '\'\Magento\Framework\Cache\Backend\RemoteSynchronizedCache\'',
62+
],
63+
];
64+
}
65+
66+
/**
67+
* @return array
68+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
69+
*/
70+
protected function goodConfigurationDataProvider(): array
71+
{
72+
return [
73+
[
74+
'version' => '2.2.11',
75+
'backendModel' => [
76+
'stage' => [
77+
'deploy' => [
78+
'REDIS_BACKEND' => 'Cm_Cache_Backend_Redis',
79+
],
80+
],
81+
],
82+
'expectedBackend' => 'Cm_Cache_Backend_Redis',
83+
'expectedConfig' => [
84+
'backend_options' => [
85+
'server' => 'redis',
86+
'port' => '6379',
87+
'database' => 1,
88+
],
89+
],
90+
],
91+
];
92+
}
93+
}

0 commit comments

Comments
 (0)