Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigFixtureTest.php
Go to the documentation of this file.
1 <?php
10 namespace Magento\Test\Annotation;
11 
12 class ConfigFixtureTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $_object;
18 
19  protected function setUp()
20  {
21  $this->_object = $this->createPartialMock(
22  \Magento\TestFramework\Annotation\ConfigFixture::class,
23  ['_getConfigValue', '_setConfigValue']
24  );
25  }
26 
30  public function testGlobalConfig()
31  {
32  $this->_object->expects(
33  $this->at(0)
34  )->method(
35  '_getConfigValue'
36  )->with(
37  'web/unsecure/base_url'
38  )->will(
39  $this->returnValue('http://localhost/')
40  );
41  $this->_object->expects(
42  $this->at(1)
43  )->method(
44  '_setConfigValue'
45  )->with(
46  'web/unsecure/base_url',
47  'http://example.com/'
48  );
49  $this->_object->startTest($this);
50 
51  $this->_object->expects(
52  $this->once()
53  )->method(
54  '_setConfigValue'
55  )->with(
56  'web/unsecure/base_url',
57  'http://localhost/'
58  );
59  $this->_object->endTest($this);
60  }
61 
65  public function testCurrentStoreConfig()
66  {
67  $this->_object->expects(
68  $this->at(0)
69  )->method(
70  '_getConfigValue'
71  )->with(
72  'dev/restrict/allow_ips',
73  ''
74  )->will(
75  $this->returnValue('127.0.0.1')
76  );
77  $this->_object->expects(
78  $this->at(1)
79  )->method(
80  '_setConfigValue'
81  )->with(
82  'dev/restrict/allow_ips',
83  '192.168.0.1',
84  ''
85  );
86  $this->_object->startTest($this);
87 
88  $this->_object->expects(
89  $this->once()
90  )->method(
91  '_setConfigValue'
92  )->with(
93  'dev/restrict/allow_ips',
94  '127.0.0.1',
95  ''
96  );
97  $this->_object->endTest($this);
98  }
99 
103  public function testSpecificStoreConfig()
104  {
105  $this->_object->expects(
106  $this->at(0)
107  )->method(
108  '_getConfigValue'
109  )->with(
110  'dev/restrict/allow_ips',
111  'admin'
112  )->will(
113  $this->returnValue('192.168.0.1')
114  );
115  $this->_object->expects(
116  $this->at(1)
117  )->method(
118  '_setConfigValue'
119  )->with(
120  'dev/restrict/allow_ips',
121  '192.168.0.2',
122  'admin'
123  );
124  $this->_object->startTest($this);
125 
126  $this->_object->expects(
127  $this->once()
128  )->method(
129  '_setConfigValue'
130  )->with(
131  'dev/restrict/allow_ips',
132  '192.168.0.1',
133  'admin'
134  );
135  $this->_object->endTest($this);
136  }
137 
138  public function testInitStoreAfterOfScope()
139  {
140  $this->_object->expects($this->never())->method('_getConfigValue');
141  $this->_object->expects($this->never())->method('_setConfigValue');
142  $this->_object->initStoreAfter();
143  }
144 
148  public function testInitStoreAfter()
149  {
150  $this->_object->startTest($this);
151  $this->_object->expects(
152  $this->at(0)
153  )->method(
154  '_getConfigValue'
155  )->with(
156  'web/unsecure/base_url'
157  )->will(
158  $this->returnValue('http://localhost/')
159  );
160  $this->_object->expects(
161  $this->at(1)
162  )->method(
163  '_setConfigValue'
164  )->with(
165  'web/unsecure/base_url',
166  'http://example.com/'
167  );
168  $this->_object->initStoreAfter();
169  }
170 }