Skip to content

Commit

Permalink
magento/magento2-jp/issues/18 : Provide possibility to customize anal…
Browse files Browse the repository at this point in the history
…yzer/tokenyzer for Elasticsearch

 - Fixed unit test for index settings builder
  • Loading branch information
Volodymyr Kublytskyi committed Aug 9, 2018
1 parent 4ab16d2 commit 9281554
Showing 1 changed file with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\Index;

use Magento\Elasticsearch\Model\Adapter\Index\Builder;
use Magento\Elasticsearch\Model\Adapter\Index\Config\EsCharFilterConfigInterface;
use Magento\Elasticsearch\Model\Adapter\Index\Config\EsStemmerConfigInterface;
use Magento\Elasticsearch\Model\Adapter\Index\Config\EsTokenFilterConfigInterface;
use Magento\Elasticsearch\Model\Adapter\Index\Config\EsTokenizerConfigInterface;
use Magento\Framework\Locale\Resolver as LocaleResolver;
use Magento\Elasticsearch\Model\Adapter\Index\Config\EsConfigInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
Expand Down Expand Up @@ -46,12 +50,43 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$stemmerConfig = $this->getMockBuilder(EsStemmerConfigInterface::class)
->getMockForAbstractClass();
$stemmerConfig->method('getStemmerInfo')->willReturn([
'type' => 'stemmer',
'default' => 'english',
'en_US' => 'english',
'de_DE' => 'german'
]);

$tokenizerConfig = $this->getMockBuilder(EsTokenizerConfigInterface::class)
->getMockForAbstractClass();
$tokenizerConfig->method('getTokenizerInfo')->willReturn([
'default' => [
'type' => 'standard',
]
]);

$tokenFilterConfig = $this->getMockBuilder(EsTokenFilterConfigInterface::class)
->getMockForAbstractClass();
$tokenFilterConfig->method('getTokenFiltersInfo')->willReturn([]);
$tokenFilterConfig->method('getTokenFiltersList')->willReturn([]);

$charFilterConfig = $this->getMockBuilder(EsCharFilterConfigInterface::class)
->getMockForAbstractClass();
$charFilterConfig->method('getCharFiltersInfo')->willReturn([]);
$charFilterConfig->method('getCharFiltersList')->willReturn([]);

$objectManager = new ObjectManagerHelper($this);
$this->model = $objectManager->getObject(
\Magento\Elasticsearch\Model\Adapter\Index\Builder::class,
[
'localeResolver' => $this->localeResolver,
'esConfig' => $this->esConfig
'esConfig' => $this->esConfig,
'stemmerConfig' => $stemmerConfig,
'tokenizerConfig' => $tokenizerConfig,
'tokenFilterConfig' => $tokenFilterConfig,
'charFilterConfig' => $charFilterConfig,
]
);
}
Expand All @@ -68,21 +103,6 @@ public function testBuild($locale)
->method('getLocale')
->willReturn($locale);

$this->esConfig->expects()
->method('getStemmerInfo')
->willReturn([
'type' => 'stemmer',
'default' => 'english',
'en_US' => 'english',
]);
$this->esConfig->expects()
->method('getTokenizerInfo')
->willReturn([
'type' => 'stemmer',
'default' => 'english',
'en_US' => 'english',
]);

$result = $this->model->build();
$this->assertNotNull($result);
}
Expand Down

0 comments on commit 9281554

Please sign in to comment.