Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConcealInProductionConfigListTest.php
Go to the documentation of this file.
1 <?php
7 
10 
16 class ConcealInProductionConfigListTest extends \PHPUnit\Framework\TestCase
17 {
21  private $stateMock;
22 
26  private $model;
27 
28  protected function setUp()
29  {
30  $this->stateMock = $this->getMockBuilder(State::class)
31  ->disableOriginalConstructor()
32  ->getMock();
33 
34  $configs = [
38  'third/path' => 'no',
39  'third/path/field' => ConcealInProductionConfigList::DISABLED,
40  'first/path/field' => 'no',
41  ];
42 
43  $this->model = new ConcealInProductionConfigList($this->stateMock, $configs);
44  }
45 
54  public function testIsDisabled($path, $mageMode, $expectedResult)
55  {
56  $this->stateMock->expects($this->once())
57  ->method('getMode')
58  ->willReturn($mageMode);
59  $this->assertSame($expectedResult, $this->model->isDisabled($path));
60  }
61 
67  public function disabledDataProvider()
68  {
69  return [
70  ['first/path', State::MODE_PRODUCTION, true],
71  ['first/path/field', State::MODE_PRODUCTION, false],
72  ['first/path/field2', State::MODE_PRODUCTION, true],
73  ['first/path', State::MODE_DEFAULT, false],
74  ['some/path', State::MODE_PRODUCTION, false],
75  ['second/path', State::MODE_PRODUCTION, false],
76  ['third', State::MODE_PRODUCTION, true],
77  ['third/path2', State::MODE_PRODUCTION, true],
78  ['third/path2/field', State::MODE_PRODUCTION, true],
79  ['third/path', State::MODE_PRODUCTION, false],
80  ['third/path/field', State::MODE_PRODUCTION, true],
81  ['third/path/field2', State::MODE_PRODUCTION, false],
82  ];
83  }
84 
93  public function testIsHidden($path, $mageMode, $expectedResult)
94  {
95  $this->stateMock->expects($this->once())
96  ->method('getMode')
97  ->willReturn($mageMode);
98  $this->assertSame($expectedResult, $this->model->isHidden($path));
99  }
100 
106  public function hiddenDataProvider()
107  {
108  return [
109  ['first/path', State::MODE_PRODUCTION, false],
110  ['first/path', State::MODE_DEFAULT, false],
111  ['some/path', State::MODE_PRODUCTION, false],
112  ['second/path', State::MODE_PRODUCTION, true],
113  ['second/path', State::MODE_DEVELOPER, false],
114  ];
115  }
116 }