13
13
use Magento \Framework \App \DeploymentConfig ;
14
14
use Magento \Framework \Config \File \ConfigFilePool ;
15
15
use Magento \Framework \Exception \FileSystemException ;
16
+ use Magento \Framework \Model \ResourceModel \AbstractResource ;
16
17
use Magento \Framework \Stdlib \ArrayManager ;
17
18
use Magento \Store \Model \ScopeInterface ;
18
19
use PHPUnit_Framework_MockObject_MockObject as Mock ;
@@ -55,6 +56,11 @@ class LockProcessorTest extends \PHPUnit_Framework_TestCase
55
56
*/
56
57
private $ valueMock ;
57
58
59
+ /**
60
+ * @var AbstractResource|Mock
61
+ */
62
+ private $ resourceMock ;
63
+
58
64
/**
59
65
* @inheritdoc
60
66
*/
@@ -73,9 +79,13 @@ protected function setUp()
73
79
->disableOriginalConstructor ()
74
80
->getMock ();
75
81
$ this ->valueMock = $ this ->getMockBuilder (Value::class)
76
- ->setMethods (['validateBeforeSave ' , 'beforeSave ' , 'setValue ' , 'getValue ' , 'afterSave ' ])
82
+ ->setMethods (['save ' , 'getResource ' , 'setValue ' , 'getValue ' , 'afterSave ' ])
77
83
->disableOriginalConstructor ()
78
84
->getMock ();
85
+ $ this ->resourceMock = $ this ->getMockBuilder (AbstractResource::class)
86
+ ->setMethods (['save ' ])
87
+ ->disableOriginalConstructor ()
88
+ ->getMockForAbstractClass ();
79
89
80
90
$ this ->model = new LockProcessor (
81
91
$ this ->preparedValueFactory ,
@@ -120,6 +130,12 @@ public function testProcess($path, $value, $scope, $scopeCode)
120
130
$ this ->valueMock ->expects ($ this ->once ())
121
131
->method ('getValue ' )
122
132
->willReturn ($ value );
133
+ $ this ->valueMock ->expects ($ this ->once ())
134
+ ->method ('getResource ' )
135
+ ->willReturn ($ this ->resourceMock );
136
+ $ this ->resourceMock ->expects ($ this ->once ())
137
+ ->method ('save ' )
138
+ ->with ($ this ->valueMock );
123
139
$ this ->deploymentConfigWriterMock ->expects ($ this ->once ())
124
140
->method ('saveConfig ' )
125
141
->with (
@@ -138,12 +154,6 @@ public function testProcess($path, $value, $scope, $scopeCode)
138
154
],
139
155
false
140
156
);
141
- $ this ->valueMock ->expects ($ this ->once ())
142
- ->method ('validateBeforeSave ' );
143
- $ this ->valueMock ->expects ($ this ->once ())
144
- ->method ('beforeSave ' );
145
- $ this ->valueMock ->expects ($ this ->once ())
146
- ->method ('afterSave ' );
147
157
148
158
$ this ->model ->process ($ path , $ value , $ scope , $ scopeCode );
149
159
}
@@ -175,6 +185,12 @@ public function testProcessNotReadableFs()
175
185
$ this ->valueMock ->expects ($ this ->once ())
176
186
->method ('getValue ' )
177
187
->willReturn ($ value );
188
+ $ this ->valueMock ->expects ($ this ->once ())
189
+ ->method ('getResource ' )
190
+ ->willReturn ($ this ->resourceMock );
191
+ $ this ->resourceMock ->expects ($ this ->once ())
192
+ ->method ('save ' )
193
+ ->with ($ this ->valueMock );
178
194
$ this ->configPathResolver ->expects ($ this ->once ())
179
195
->method ('resolve ' )
180
196
->willReturn ('system/default/test/test/test ' );
@@ -207,9 +223,10 @@ public function testCustomException()
207
223
$ this ->arrayManagerMock ->expects ($ this ->never ())
208
224
->method ('set ' );
209
225
$ this ->valueMock ->expects ($ this ->once ())
210
- ->method ('getValue ' );
211
- $ this ->valueMock ->expects ($ this ->once ())
212
- ->method ('afterSave ' )
226
+ ->method ('getResource ' )
227
+ ->willReturn ($ this ->resourceMock );
228
+ $ this ->resourceMock ->expects ($ this ->once ())
229
+ ->method ('save ' )
213
230
->willThrowException (new \Exception ('Invalid values ' ));
214
231
$ this ->deploymentConfigWriterMock ->expects ($ this ->never ())
215
232
->method ('saveConfig ' );
0 commit comments