56 private $serializerMock;
65 $this->storeManager = $this->getMockBuilder(\
Magento\Store\Model\StoreManagerInterface::class)
66 ->disableOriginalConstructor()
68 $this->localeResolver = $this->getMockBuilder(\
Magento\Framework\Locale\Resolver::class)
69 ->disableOriginalConstructor()
75 $this->readFactory = $this->getMockBuilder(\
Magento\Framework\Filesystem\Directory\ReadFactory::class)
76 ->disableOriginalConstructor()
77 ->setMethods([
'create'])
79 $this->configCache = $this->getMockBuilder(\
Magento\Framework\
App\Cache\Type\Config::class)
80 ->disableOriginalConstructor()
82 $this->esConfig = $this->getMockBuilder(
84 )->disableOriginalConstructor()->getMock();
86 $this->serializerMock = $this->createMock(SerializerInterface::class);
92 'storeManager' => $this->storeManager,
93 'localeResolver' => $this->localeResolver,
94 'readFactory' => $this->readFactory,
95 'configCache' => $this->configCache,
96 'esConfig' => $this->esConfig,
97 'stopwordsModule' =>
'',
98 'stopwordsDirectory' =>
'' 104 $this->serializerMock
113 $stopWordsFromFile =
"a\nthe\nof";
114 $stopWords = [
'a',
'the',
'of'];
115 $serializedStopWords =
'serialized stop words';
116 $this->esConfig->expects($this->once())
117 ->method(
'getStopwordsInfo')
119 'default' =>
'default.csv',
121 $storeInterface = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
122 ->disableOriginalConstructor()
124 $this->storeManager->expects($this->once())
126 ->willReturn($storeInterface);
127 $storeInterface->expects($this->once())
130 $this->localeResolver->expects($this->once())
131 ->method(
'getLocale')
132 ->willReturn(
'en_US');
134 $read = $this->getMockBuilder(\
Magento\Framework\Filesystem\Directory\Read::class)
135 ->disableOriginalConstructor()
137 $this->readFactory->expects($this->once())
140 $read->expects($this->once())
145 $this->configCache->expects($this->once())
149 $read->expects($this->once())
151 ->willReturn($stopWordsFromFile);
152 $this->serializerMock->expects($this->once())
153 ->method(
'serialize')
155 ->willReturn($serializedStopWords);
156 $this->configCache->expects($this->once())
159 $serializedStopWords,
165 $this->model->process(
'the test of a query')
174 $serializedStopWords =
'serialized stop words';
175 $this->esConfig->expects($this->once())
176 ->method(
'getStopwordsInfo')
178 'default' =>
'default.csv',
180 $storeInterface = $this->getMockBuilder(\
Magento\Store\Api\Data\StoreInterface::class)
181 ->disableOriginalConstructor()
183 $this->storeManager->expects($this->once())
185 ->willReturn($storeInterface);
186 $storeInterface->expects($this->once())
189 $this->localeResolver->expects($this->once())
190 ->method(
'getLocale')
191 ->willReturn(
'en_US');
193 $read = $this->getMockBuilder(\
Magento\Framework\Filesystem\Directory\Read::class)
194 ->disableOriginalConstructor()
196 $this->readFactory->expects($this->once())
199 $read->expects($this->once())
204 $this->configCache->expects($this->once())
206 ->willReturn($serializedStopWords);
207 $this->serializerMock->expects($this->once())
208 ->method(
'unserialize')
209 ->with($serializedStopWords)
210 ->willReturn([
'a',
'the',
'of']);
214 $this->model->process(
'the test of a query')