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 
9 
16 class ConfigTest extends \PHPUnit\Framework\TestCase
17 {
21  protected $appConfig;
22 
26  protected $model;
27 
28  protected function setUp()
29  {
30  $this->appConfig = $this->createPartialMock(\Magento\Framework\App\Config::class, ['get']);
31  $this->model = new \Magento\Backend\App\Config($this->appConfig);
32  }
33 
34  public function testGetValue()
35  {
36  $expectedValue = 'some value';
37  $path = 'some path';
38  $this->appConfig->expects(
39  $this->once()
40  )->method(
41  'get'
42  )->with(
43  $this->equalTo('system'),
44  $this->equalTo('default/' . $path),
45  $this->isNull()
46  )->will(
47  $this->returnValue($expectedValue)
48  );
49  $this->assertEquals($expectedValue, $this->model->getValue($path));
50  }
51 
58  public function testIsSetFlag($configPath, $configValue, $expectedResult)
59  {
60  $this->appConfig->expects(
61  $this->any()
62  )->method(
63  'get'
64  )->with(
65  $this->equalTo('system'),
66  $this->equalTo('default/' . $configPath)
67  )->will(
68  $this->returnValue($configValue)
69  );
70  $this->assertEquals($expectedResult, $this->model->isSetFlag($configPath));
71  }
72 
76  public function isSetFlagDataProvider()
77  {
78  return [
79  ['a', 0, false],
80  ['b', true, true],
81  ['c', '0', false],
82  ['d', '', false],
83  ['e', 'some string', true],
84  ['f', 1, true]
85  ];
86  }
87 
94  protected function getConfigDataMock($mockedMethod)
95  {
96  return $this->createPartialMock(\Magento\Framework\App\Config\Data::class, [$mockedMethod]);
97  }
98 }
testIsSetFlag($configPath, $configValue, $expectedResult)
Definition: ConfigTest.php:58