15 use PHPUnit_Framework_MockObject_MockObject as MockObject;
27 private $arrayManagerMock;
32 private $preparedValueFactoryMock;
37 private $valueInterfaceMock;
54 $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class)
55 ->disableOriginalConstructor()
57 $this->writerMock = $this->getMockBuilder(Writer::class)
58 ->disableOriginalConstructor()
60 $this->preparedValueFactoryMock = $this->getMockBuilder(PreparedValueFactory::class)
61 ->disableOriginalConstructor()
64 $this->valueInterfaceMock = $this->getMockBuilder(ValueInterface::class)
65 ->getMockForAbstractClass();
66 $this->valueMock = $this->getMockBuilder(Value::class)
67 ->disableOriginalConstructor()
68 ->setMethods([
'validateBeforeSave',
'beforeSave',
'getValue',
'afterSave'])
73 $this->arrayManagerMock,
74 $this->preparedValueFactoryMock
81 'some1/config1/path1' =>
'someValue1',
82 'some2/config2/path2' =>
'someValue2',
83 'some3/config3/path3' =>
'someValue3' 87 $this->preparedValueFactoryMock->expects($this->exactly(3))
90 [
'some1/config1/path1',
'someValue1',
'scope',
'scope_code'],
91 [
'some2/config2/path2',
'someValue2',
'scope',
'scope_code'],
92 [
'some3/config3/path3',
'someValue3',
'scope',
'scope_code']
94 ->willReturnOnConsecutiveCalls(
95 $this->valueInterfaceMock,
100 $this->valueMock->expects($this->exactly(2))
101 ->method(
'validateBeforeSave');
102 $this->valueMock->expects($this->exactly(2))
103 ->method(
'beforeSave');
104 $this->valueMock->expects($this->exactly(2))
106 ->willReturnOnConsecutiveCalls(
'someValue2',
'someValue3');
107 $this->valueMock->expects($this->exactly(2))
108 ->method(
'afterSave');
110 $this->arrayManagerMock->expects($this->exactly(3))
113 [
'system/scope/scope_code/some1/config1/path1', $this->anything(),
'someValue1'],
114 [
'system/scope/scope_code/some2/config2/path2', $this->anything(),
'someValue2'],
115 [
'system/scope/scope_code/some3/config3/path3', $this->anything(),
'someValue3']
118 $this->writerMock->expects($this->once())
119 ->method(
'saveConfig')
122 $this->model->save(
$values,
'scope',
'scope_code');
128 'some1/config1/path1' =>
'someValue1',
129 'some2/config2/path2' =>
'someValue2',
130 'some3/config3/path3' =>
'someValue3' 134 $this->preparedValueFactoryMock->expects($this->exactly(3))
137 [
'some1/config1/path1',
'someValue1',
'default'],
138 [
'some2/config2/path2',
'someValue2',
'default'],
139 [
'some3/config3/path3',
'someValue3',
'default']
141 ->willReturnOnConsecutiveCalls(
142 $this->valueInterfaceMock,
147 $this->valueMock->expects($this->exactly(2))
148 ->method(
'validateBeforeSave');
149 $this->valueMock->expects($this->exactly(2))
150 ->method(
'beforeSave');
151 $this->valueMock->expects($this->exactly(2))
153 ->willReturnOnConsecutiveCalls(
'someValue2',
'someValue3');
154 $this->valueMock->expects($this->exactly(2))
155 ->method(
'afterSave');
157 $this->arrayManagerMock->expects($this->exactly(3))
160 [
'system/default/some1/config1/path1', $this->anything(),
'someValue1'],
161 [
'system/default/some2/config2/path2', $this->anything(),
'someValue2'],
162 [
'system/default/some3/config3/path3', $this->anything(),
'someValue3']
165 $this->writerMock->expects($this->once())
166 ->method(
'saveConfig')
179 'some1/config1/path1' =>
null,
182 $this->preparedValueFactoryMock->expects($this->never())->method(
'create');
184 $this->writerMock->expects($this->once())
185 ->method(
'saveConfig')