localeResolver = $this->getMockBuilder(\Magento\Framework\Locale\Resolver::class) ->disableOriginalConstructor() ->setMethods([ 'emulate', 'getLocale' ]) ->getMock(); $this->esConfig = $this->getMockBuilder( \Magento\Elasticsearch\Model\Adapter\Index\Config\EsConfigInterface::class ) ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManagerHelper($this); $this->model = $objectManager->getObject( \Magento\Elasticsearch\Model\Adapter\Index\Builder::class, [ 'localeResolver' => $this->localeResolver, 'esConfig' => $this->esConfig ] ); } /** * Test build() method * * @param string $locale * @dataProvider buildDataProvider */ public function testBuild($locale) { $this->localeResolver->expects($this->once()) ->method('getLocale') ->willReturn($locale); $this->esConfig->expects($this->once()) ->method('getStemmerInfo') ->willReturn([ 'type' => 'stemmer', 'default' => 'english', 'en_US' => 'english', ]); $result = $this->model->build(); $this->assertNotNull($result); } /** * Test setStoreId() method */ public function testSetStoreId() { $result = $this->model->setStoreId(1); $this->assertNull($result); } /** * @return array */ public function buildDataProvider() { return [ ['en_US'], ['de_DE'], ]; } }