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  private $dataInterfaceMock;
21 
25  private $objectManagerHelper;
26 
30  private $config;
31 
35  protected function setUp()
36  {
37  $this->dataInterfaceMock = $this->getMockBuilder(DataInterface::class)
38  ->disableOriginalConstructor()
39  ->getMock();
40 
41  $this->objectManagerHelper = new ObjectManagerHelper($this);
42 
43  $this->config = $this->objectManagerHelper->getObject(
44  Config::class,
45  [
46  'data' => $this->dataInterfaceMock,
47  ]
48  );
49  }
50 
54  public function testGet()
55  {
56  $key = 'configKey';
57  $defaultValue = 'mock';
58  $configValue = 'emptyString';
59 
60  $this->dataInterfaceMock
61  ->expects($this->once())
62  ->method('get')
63  ->with($key, $defaultValue)
64  ->willReturn($configValue);
65 
66  $this->assertSame($configValue, $this->config->get($key, $defaultValue));
67  }
68 }