9 use \Magento\Framework\App\MaintenanceMode;
25 $this->flagDir = $this->getMockForAbstractClass(\
Magento\Framework\
Filesystem\Directory\WriteInterface::class);
28 ->method(
'getDirectoryWrite')
29 ->will($this->returnValue($this->flagDir));
36 $this->flagDir->expects($this->once())->method(
'isExist')
38 ->will($this->returnValue(
false));
39 $this->assertFalse($this->model->isOn());
48 $this->flagDir->expects($this->exactly(2))->method(
'isExist')
49 ->will(($this->returnValueMap($mapisExist)));
50 $this->assertTrue($this->model->isOn());
59 $this->flagDir->expects($this->exactly(2))->method(
'isExist')
60 ->will(($this->returnValueMap($mapisExist)));
61 $this->assertFalse($this->model->isOn());
66 $this->flagDir->expects($this->once())->method(
'isExist')
69 $this->assertFalse($this->model->isOn());
75 ->will($this->returnValue(
false));
76 $this->flagDir->expects($this->at(1))->method(
'touch')->will($this->returnValue(
true));
78 ->will($this->returnValue(
true));
80 ->will($this->returnValue(
false));
82 $this->assertFalse($this->model->isOn());
83 $this->assertTrue($this->model->set(
true));
84 $this->assertTrue($this->model->isOn());
90 ->will($this->returnValue(
true));
92 ->will($this->returnValue(
false));
94 ->will($this->returnValue(
false));
96 $this->assertFalse($this->model->set(
false));
97 $this->assertFalse($this->model->isOn());
106 $this->flagDir->expects($this->any())->method(
'isExist')->will($this->returnValueMap($mapisExist));
107 $this->flagDir->expects($this->any())->method(
'writeFile')
109 ->will($this->returnValue(
true));
111 $this->flagDir->expects($this->any())->method(
'readFile')
113 ->will($this->returnValue(
''));
115 $this->model->setAddresses(
'');
116 $this->assertEquals([
''], $this->model->getAddressInfo());
125 $this->flagDir->expects($this->any())->method(
'isExist')->will($this->returnValueMap($mapisExist));
126 $this->flagDir->expects($this->any())->method(
'delete')->will($this->returnValueMap($mapisExist));
128 $this->flagDir->expects($this->any())->method(
'writeFile')
129 ->will($this->returnValue(10));
131 $this->flagDir->expects($this->any())->method(
'readFile')
133 ->will($this->returnValue(
'address1'));
135 $this->model->setAddresses(
'address1');
136 $this->assertEquals([
'address1'], $this->model->getAddressInfo());
145 $this->flagDir->expects($this->any())->method(
'isExist')->will($this->returnValueMap($mapisExist));
146 $this->flagDir->expects($this->any())->method(
'delete')->will($this->returnValueMap($mapisExist));
148 $this->flagDir->expects($this->any())->method(
'writeFile')
149 ->will($this->returnValue(10));
151 $this->flagDir->expects($this->any())->method(
'readFile')
153 ->will($this->returnValue(
'address1,10.50.60.123'));
155 $expectedArray = [
'address1',
'10.50.60.123'];
156 $this->model->setAddresses(
'address1,10.50.60.123');
157 $this->assertEquals($expectedArray, $this->model->getAddressInfo());
158 $this->assertFalse($this->model->isOn(
'address1'));
159 $this->assertTrue($this->model->isOn(
'address3'));
168 $this->flagDir->expects($this->any())->method(
'isExist')->will($this->returnValueMap($mapisExist));
169 $this->flagDir->expects($this->any())->method(
'delete')->will($this->returnValueMap($mapisExist));
171 $this->flagDir->expects($this->any())->method(
'readFile')
173 ->will($this->returnValue(
'address1,10.50.60.123'));
175 $expectedArray = [
'address1',
'10.50.60.123'];
176 $this->model->setAddresses(
'address1,10.50.60.123');
177 $this->assertEquals($expectedArray, $this->model->getAddressInfo());
178 $this->assertFalse($this->model->isOn(
'address1'));
179 $this->assertFalse($this->model->isOn(
'address3'));
testOnSetMultipleAddresses()
testisOnWithIPNoMaintenance()
testOffSetMultipleAddresses()