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