Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigTest.php
Go to the documentation of this file.
1 <?php
7 
11 
15 class ConfigTest extends \PHPUnit\Framework\TestCase
16 {
20  protected $model;
21 
25  protected $scopeConfig;
26 
32  protected function setUp()
33  {
34  $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
35  ->disableOriginalConstructor()
36  ->getMock();
37 
38  $objectManager = new ObjectManagerHelper($this);
39  $this->model = $objectManager->getObject(
40  \Magento\Elasticsearch\Model\Config::class,
41  [
42  'scopeConfig' => $this->scopeConfig
43  ]
44  );
45  }
46 
50  public function testPrepareClientOptions()
51  {
52  $this->scopeConfig->expects($this->any())
53  ->method('getValue')
54  ->willReturn('');
55  $options = [
56  'hostname' => 'localhost',
57  'port' => '9200',
58  'index' => 'magento2',
59  'enableAuth' => '1',
60  'username' => 'user',
61  'password' => 'pass',
62  'timeout' => 1,
63  ];
64  $this->assertEquals($options, $this->model->prepareClientOptions($options));
65  }
66 
70  public function testGetIndexPrefix()
71  {
72  $this->scopeConfig->expects($this->any())
73  ->method('getValue')
74  ->willReturn('indexPrefix');
75  $this->assertEquals('indexPrefix', $this->model->getIndexPrefix());
76  }
77 
81  public function testGetEntityType()
82  {
83  $this->assertInternalType('string', $this->model->getEntityType());
84  }
85 
89  public function testIsElasticsearchEnabled()
90  {
91  $this->assertFalse($this->model->isElasticsearchEnabled());
92  }
93 }
$objectManager
Definition: bootstrap.php:17