Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EnableEavIndexerTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
16 class EnableEavIndexerTest extends \PHPUnit\Framework\TestCase
17 {
21  private $model;
22 
26  private $config;
27 
33  protected function setUp()
34  {
35  $this->config = $this->getMockBuilder(\Magento\Config\Model\Config::class)
36  ->disableOriginalConstructor()
37  ->setMethods(['getData', 'setData'])
38  ->getMock();
39 
40  $objectManagerHelper = new ObjectManagerHelper($this);
41  $this->model = $objectManagerHelper->getObject(
42  \Magento\CatalogSearch\Plugin\EnableEavIndexer::class
43  );
44  }
45 
51  public function testBeforeSave()
52  {
53  $this->config->expects($this->once())->method('getData')->willReturn('elasticsearch');
54  $this->config->expects($this->never())->method('setData')->willReturnSelf();
55 
56  $this->model->beforeSave($this->config);
57  }
58 
65  {
66  $this->config->expects($this->at(0))->method('getData')->willReturn('mysql');
67  $this->config->expects($this->at(1))->method('getData')->willReturn([]);
68  $this->config->expects($this->once())->method('setData')->willReturnSelf();
69 
70  $this->model->beforeSave($this->config);
71  }
72 }