File tree Expand file tree Collapse file tree 6 files changed +9
-65
lines changed Expand file tree Collapse file tree 6 files changed +9
-65
lines changed Original file line number Diff line number Diff line change @@ -63,30 +63,13 @@ public function configure(array $inputOptions)
63
63
$ configKey = $ this ->searchConfigMapping [$ inputKey ];
64
64
$ this ->configWriter ->save (self ::CATALOG_SEARCH . $ configKey , $ inputValue );
65
65
}
66
-
67
- if ($ this ->doValidation ($ inputOptions )) {
68
- if (!$ this ->validator ->validate ($ inputOptions [SearchConfigOptionsList::INPUT_KEY_SEARCH_ENGINE ])) {
69
- throw new InputException (
70
- __ (
71
- 'Connection to Elasticsearch cannot be established. '
72
- . 'Please check the configuration and try again. '
73
- )
74
- );
75
- }
76
- }
77
- }
78
-
79
- /**
80
- * Check if elasticsearch validation should be performed
81
- *
82
- * @param array $inputOptions
83
- * @return bool
84
- */
85
- private function doValidation (array $ inputOptions ): bool
86
- {
87
- if (isset ($ inputOptions [SearchConfigOptionsList::INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION ])) {
88
- return !$ inputOptions [SearchConfigOptionsList::INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION ];
66
+ if (!$ this ->validator ->validate ($ inputOptions [SearchConfigOptionsList::INPUT_KEY_SEARCH_ENGINE ])) {
67
+ throw new InputException (
68
+ __ (
69
+ 'Connection to Elasticsearch cannot be established. '
70
+ . 'Please check the configuration and try again. '
71
+ )
72
+ );
89
73
}
90
- return true ;
91
74
}
92
75
}
Original file line number Diff line number Diff line change @@ -112,30 +112,4 @@ public function testConfigureValidateFail()
112
112
113
113
$ this ->installConfig ->configure ($ inputOptions );
114
114
}
115
-
116
- public function testConfigureWithSkipValidation ()
117
- {
118
- $ inputOptions = [
119
- 'search-engine ' => 'elasticsearch5 ' ,
120
- 'elasticsearch-host ' => 'localhost ' ,
121
- 'elasticsearch-port ' => '9200 ' ,
122
- 'skip-elasticsearch-validation ' => true
123
- ];
124
-
125
- $ this ->configWriterMock
126
- ->expects ($ this ->at (0 ))
127
- ->method ('save ' )
128
- ->with ('catalog/search/engine ' , 'elasticsearch5 ' );
129
- $ this ->configWriterMock
130
- ->expects ($ this ->at (1 ))
131
- ->method ('save ' )
132
- ->with ('catalog/search/elasticsearch5_server_hostname ' , 'localhost ' );
133
- $ this ->configWriterMock
134
- ->expects ($ this ->at (2 ))
135
- ->method ('save ' )
136
- ->with ('catalog/search/elasticsearch5_server_port ' , '9200 ' );
137
- $ this ->validatorMock ->expects ($ this ->never ())->method ('validate ' );
138
-
139
- $ this ->installConfig ->configure ($ inputOptions );
140
- }
141
115
}
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function configure(array $inputOptions)
35
35
$ searchEngine = $ inputOptions ['search-engine ' ];
36
36
37
37
if (!isset ($ this ->installConfigList [$ searchEngine ])) {
38
- throw new InputException (__ ('Unable to configure search engine: ' . $ searchEngine ));
38
+ throw new InputException (__ ('Unable to configure search engine: %1 ' , $ searchEngine ));
39
39
}
40
40
$ installConfig = $ this ->installConfigList [$ searchEngine ];
41
41
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ class SearchConfigOptionsList
30
30
const INPUT_KEY_ELASTICSEARCH_PASSWORD = 'elasticsearch-password ' ;
31
31
const INPUT_KEY_ELASTICSEARCH_INDEX_PREFIX = 'elasticsearch-index-prefix ' ;
32
32
const INPUT_KEY_ELASTICSEARCH_TIMEOUT = 'elasticsearch-timeout ' ;
33
- const INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION = 'skip-elasticsearch-validation ' ;
34
33
35
34
/**
36
35
* Default values
@@ -102,12 +101,6 @@ public function getOptionsList(): array
102
101
'' ,
103
102
'Elasticsearch server timeout. ' ,
104
103
self ::DEFAULT_ELASTICSEARCH_TIMEOUT
105
- ),
106
- new FlagConfigOption (
107
- self ::INPUT_KEY_ELASTICSEARCH_SKIP_VALIDATION ,
108
- '' ,
109
- 'Skip Elasticsearch connection validation. ' ,
110
- null
111
104
)
112
105
];
113
106
}
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ protected function setup()
30
30
public function testGetOptionsList ()
31
31
{
32
32
$ optionsList = $ this ->searchConfigOptionsList ->getOptionsList ();
33
- $ this ->assertCount (9 , $ optionsList );
33
+ $ this ->assertCount (8 , $ optionsList );
34
34
35
35
$ this ->assertArrayHasKey (0 , $ optionsList );
36
36
$ this ->assertInstanceOf (SelectConfigOption::class, $ optionsList [0 ]);
@@ -67,9 +67,5 @@ public function testGetOptionsList()
67
67
$ this ->assertArrayHasKey (7 , $ optionsList );
68
68
$ this ->assertInstanceOf (TextConfigOption::class, $ optionsList [7 ]);
69
69
$ this ->assertEquals ('elasticsearch-timeout ' , $ optionsList [7 ]->getName ());
70
-
71
- $ this ->assertArrayHasKey (8 , $ optionsList );
72
- $ this ->assertInstanceOf (FlagConfigOption::class, $ optionsList [8 ]);
73
- $ this ->assertEquals ('skip-elasticsearch-validation ' , $ optionsList [8 ]->getName ());
74
70
}
75
71
}
Original file line number Diff line number Diff line change @@ -112,7 +112,6 @@ public function installInputDataProvider()
112
112
'elasticsearch-enable-auth ' => false ,
113
113
'elasticsearch-index-prefix ' => 'magento2 ' ,
114
114
'elasticsearch-timeout ' => 15 ,
115
- 'skip-elasticsearch-validation ' => false ,
116
115
'no-interaction ' => false ,
117
116
],
118
117
'search ' => [
@@ -122,7 +121,6 @@ public function installInputDataProvider()
122
121
'elasticsearch-enable-auth ' => false ,
123
122
'elasticsearch-index-prefix ' => 'magento2 ' ,
124
123
'elasticsearch-timeout ' => 15 ,
125
- 'skip-elasticsearch-validation ' => false ,
126
124
]
127
125
]
128
126
];
You can’t perform that action at this time.
0 commit comments