7
7
8
8
namespace Magento \Elasticsearch \Test \Unit \Model ;
9
9
10
- use Magento \AdvancedSearch \Model \Client \ClientResolver ;
11
10
use Magento \Elasticsearch \Model \Config ;
12
11
use Magento \Framework \App \Config \ScopeConfigInterface ;
13
- use Magento \Store \Model \ScopeInterface ;
14
12
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
15
13
use PHPUnit \Framework \MockObject \MockObject ;
16
14
use PHPUnit \Framework \TestCase ;
17
15
18
- /**
19
- * Elasticsearch config model tests.
20
- */
21
16
class ConfigTest extends TestCase
22
17
{
23
18
/**
@@ -28,17 +23,7 @@ class ConfigTest extends TestCase
28
23
/**
29
24
* @var ScopeConfigInterface|MockObject
30
25
*/
31
- protected $ scopeConfigMock ;
32
-
33
- /**
34
- * @var ClientResolver|MockObject
35
- */
36
- private $ clientResolverMock ;
37
-
38
- /**
39
- * @var ObjectManagerHelper
40
- */
41
- private $ objectManager ;
26
+ protected $ scopeConfig ;
42
27
43
28
/**
44
29
* Setup
@@ -47,17 +32,15 @@ class ConfigTest extends TestCase
47
32
*/
48
33
protected function setUp (): void
49
34
{
50
- $ this ->scopeConfigMock = $ this ->getMockBuilder (ScopeConfigInterface::class)
35
+ $ this ->scopeConfig = $ this ->getMockBuilder (ScopeConfigInterface::class)
51
36
->disableOriginalConstructor ()
52
37
->getMockForAbstractClass ();
53
- $ this ->clientResolverMock = $ this ->createMock (ClientResolver::class);
54
38
55
- $ this -> objectManager = new ObjectManagerHelper ($ this );
56
- $ this ->model = $ this -> objectManager ->getObject (
39
+ $ objectManager = new ObjectManagerHelper ($ this );
40
+ $ this ->model = $ objectManager ->getObject (
57
41
Config::class,
58
42
[
59
- 'scopeConfig ' => $ this ->scopeConfigMock ,
60
- 'clientResolver ' => $ this ->clientResolverMock ,
43
+ 'scopeConfig ' => $ this ->scopeConfig
61
44
]
62
45
);
63
46
}
@@ -67,7 +50,7 @@ protected function setUp(): void
67
50
*/
68
51
public function testPrepareClientOptions ()
69
52
{
70
- $ this ->scopeConfigMock ->expects ($ this ->any ())
53
+ $ this ->scopeConfig ->expects ($ this ->any ())
71
54
->method ('getValue ' )
72
55
->willReturn ('' );
73
56
$ options = [
@@ -87,7 +70,7 @@ public function testPrepareClientOptions()
87
70
*/
88
71
public function testGetIndexPrefix ()
89
72
{
90
- $ this ->scopeConfigMock ->expects ($ this ->any ())
73
+ $ this ->scopeConfig ->expects ($ this ->any ())
91
74
->method ('getValue ' )
92
75
->willReturn ('indexPrefix ' );
93
76
$ this ->assertEquals ('indexPrefix ' , $ this ->model ->getIndexPrefix ());
@@ -108,51 +91,4 @@ public function testIsElasticsearchEnabled()
108
91
{
109
92
$ this ->assertFalse ($ this ->model ->isElasticsearchEnabled ());
110
93
}
111
-
112
- /**
113
- * Test retrieve search engine configuration information.
114
- *
115
- * @return void
116
- */
117
- public function testGetElasticsearchConfigData (): void
118
- {
119
- $ fieldName = 'server_hostname ' ;
120
-
121
- $ this ->clientResolverMock ->expects ($ this ->once ())
122
- ->method ('getCurrentEngine ' )
123
- ->willReturn (Config::ENGINE_NAME );
124
-
125
- $ this ->scopeConfigMock ->expects ($ this ->once ())
126
- ->method ('getValue ' )
127
- ->with ('catalog/search/ ' . Config::ENGINE_NAME . '_ ' . $ fieldName , ScopeInterface::SCOPE_STORE , 1 );
128
-
129
- $ this ->model ->getElasticsearchConfigData ($ fieldName , 1 );
130
- }
131
-
132
- /**
133
- * Test retrieve search engine configuration information with predefined prefix.
134
- *
135
- * @return void
136
- */
137
- public function testGetElasticsearchConfigDataWithPredefinedPrefix (): void
138
- {
139
- $ fieldName = 'server_hostname ' ;
140
- $ model = $ this ->objectManager ->getObject (
141
- Config::class,
142
- [
143
- 'scopeConfig ' => $ this ->scopeConfigMock ,
144
- 'clientResolver ' => $ this ->clientResolverMock ,
145
- 'prefix ' => Config::ENGINE_NAME ,
146
- ]
147
- );
148
-
149
- $ this ->clientResolverMock ->expects ($ this ->never ())
150
- ->method ('getCurrentEngine ' );
151
-
152
- $ this ->scopeConfigMock ->expects ($ this ->once ())
153
- ->method ('getValue ' )
154
- ->with ('catalog/search/ ' . Config::ENGINE_NAME . '_ ' . $ fieldName , ScopeInterface::SCOPE_STORE , 1 );
155
-
156
- $ model ->getElasticsearchConfigData ($ fieldName , 1 );
157
- }
158
94
}
0 commit comments