19 private $configOptionsList;
24 private $validatorMock;
29 private $deploymentConfigMock;
36 $this->validatorMock = $this->createMock(RedisConnectionValidator::class);
37 $this->deploymentConfigMock = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
39 $this->configOptionsList =
new CacheConfigOptionsList($this->validatorMock);
47 $options = $this->configOptionsList->getOptions();
50 $this->assertArrayHasKey(0,
$options);
51 $this->assertInstanceOf(SelectConfigOption::class,
$options[0]);
52 $this->assertEquals(
'cache-backend',
$options[0]->getName());
54 $this->assertArrayHasKey(1,
$options);
55 $this->assertInstanceOf(TextConfigOption::class,
$options[1]);
56 $this->assertEquals(
'cache-backend-redis-server',
$options[1]->getName());
58 $this->assertArrayHasKey(2,
$options);
59 $this->assertInstanceOf(TextConfigOption::class,
$options[2]);
60 $this->assertEquals(
'cache-backend-redis-db',
$options[2]->getName());
62 $this->assertArrayHasKey(3,
$options);
63 $this->assertInstanceOf(TextConfigOption::class,
$options[3]);
64 $this->assertEquals(
'cache-backend-redis-port',
$options[3]->getName());
66 $this->assertArrayHasKey(4,
$options);
67 $this->assertInstanceOf(TextConfigOption::class,
$options[4]);
68 $this->assertEquals(
'cache-backend-redis-password',
$options[4]->getName());
76 $this->deploymentConfigMock->method(
'get')->willReturn(
'');
78 $expectedConfigData = [
82 'backend' =>
'Cm_Cache_Backend_Redis',
83 'backend_options' => [
94 $configData = $this->configOptionsList->createConfig([
'cache-backend'=>
'redis'], $this->deploymentConfigMock);
96 $this->assertEquals($expectedConfigData,
$configData->getData());
104 $expectedConfigData = [
108 'backend' =>
'Cm_Cache_Backend_Redis',
109 'backend_options' => [
110 'server' =>
'localhost',
120 'cache-backend' =>
'redis',
121 'cache-backend-redis-server' =>
'localhost',
122 'cache-backend-redis-port' =>
'1234',
123 'cache-backend-redis-db' =>
'5' 126 $configData = $this->configOptionsList->createConfig(
$options, $this->deploymentConfigMock);
128 $this->assertEquals($expectedConfigData,
$configData->getData());
137 'cache-backend' =>
'redis',
138 'cache-backend-redis-server' =>
'localhost',
140 $this->validatorMock->expects($this->once())
141 ->method(
'isValidConnection')
142 ->with([
'host'=>
'localhost',
'db'=>
'',
'port'=>
'',
'password'=>
''])
145 $errors = $this->configOptionsList->validate(
$options, $this->deploymentConfigMock);
155 $invalidCacheOption =
'clay-tablet';
156 $options = [
'cache-backend' => $invalidCacheOption];
158 $errors = $this->configOptionsList->validate(
$options, $this->deploymentConfigMock);
160 $this->assertCount(1,
$errors);
161 $this->assertEquals(
"Invalid cache handler 'clay-tablet'",
$errors[0]);
testValidateWithValidInput()
testCreateConfigWithRedisConfig()
testCreateConfigCacheRedis()
testValidateWithInvalidInput()