Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SearchIndexNameResolverTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class SearchIndexNameResolverTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $model;
18 
22  protected $clientConfig;
23 
27  protected $objectManager;
28 
32  protected $indexId;
33 
37  protected $storeId;
38 
43  protected function setUp()
44  {
45  $this->clientConfig = $this->getMockBuilder(\Magento\Elasticsearch\Model\Config::class)
46  ->disableOriginalConstructor()
47  ->setMethods([
48  'getIndexPrefix',
49  'getEntityType',
50  'getIndexSettings',
51  ])
52  ->getMock();
53 
54  $this->clientConfig->expects($this->any())
55  ->method('getIndexPrefix')
56  ->willReturn('indexName');
57 
58  $this->indexId = 'catalogsearch_fulltext';
59  $this->storeId = 1;
60 
61  $objectManager = new ObjectManagerHelper($this);
62  $this->model = $objectManager->getObject(
63  \Magento\Elasticsearch\SearchAdapter\SearchIndexNameResolver::class,
64  [
65  'clientConfig' => $this->clientConfig,
66  ]
67  );
68  }
69 
74  {
75  $this->assertEquals(
76  'indexName_product_1',
77  $this->model->getIndexName($this->storeId, $this->indexId)
78  );
79  }
80 
84  public function testGetIndexName()
85  {
86  $this->assertEquals(
87  'indexName_else_index_id_1',
88  $this->model->getIndexName($this->storeId, 'else_index_id')
89  );
90  }
91 }