@@ -77,14 +77,13 @@ public function testConstruct()
77
77
$ this ->assertAttributeEquals (self ::SOURCE_CLASS . 'Abstract ' , '_resultClassName ' , $ this ->_model );
78
78
79
79
// with all arguments
80
- $ ioObject = $ this ->getMock ('Magento\Framework\Code\Generator\Io ' , [], [], '' , false );
81
- $ codeGenerator = $ this ->getMock (
82
- 'Magento\Framework\Code\Generator\ClassGenerator ' ,
83
- [],
84
- [],
85
- '' ,
86
- false
87
- );
80
+ // Configure IoObject mock
81
+ $ ioObject = $ this ->getMockBuilder ('Magento\Framework\Code\Generator\Io ' )
82
+ ->disableOriginalConstructor ()
83
+ ->getMock ();
84
+ $ codeGenerator = $ this ->getMockBuilder ('Magento\Framework\Code\Generator\ClassGenerator ' )
85
+ ->disableOriginalConstructor ()
86
+ ->getMock ();
88
87
89
88
$ this ->_model = $ this ->getMockForAbstractClass (
90
89
'Magento\Framework\Code\Generator\EntityAbstract ' ,
@@ -114,27 +113,18 @@ public function generateDataProvider()
114
113
'$sourceClassExists ' => true ,
115
114
'$resultClassExists ' => true ,
116
115
],
117
- 'cant_create_generation_directory ' => [
118
- '$errors ' => ['Can \'t create directory ' . self ::GENERATION_DIRECTORY . '. ' ],
119
- '$validationSuccess ' => false ,
120
- '$sourceClassExists ' => true ,
121
- '$resultClassExists ' => false ,
122
- '$makeGenerationDirSuccess ' => false ,
123
- ],
124
116
'cant_create_result_directory ' => [
125
117
'$errors ' => ['Can \'t create directory ' . self ::RESULT_DIRECTORY . '. ' ],
126
118
'$validationSuccess ' => false ,
127
119
'$sourceClassExists ' => true ,
128
120
'$resultClassExists ' => false ,
129
- '$makeGenerationDirSuccess ' => true ,
130
121
'$makeResultDirSuccess ' => false ,
131
122
],
132
123
'result_file_exists ' => [
133
124
'$errors ' => [],
134
125
'$validationSuccess ' => true ,
135
126
'$sourceClassExists ' => true ,
136
127
'$resultClassExists ' => false ,
137
- '$makeGenerationDirSuccess ' => false ,
138
128
'$makeResultDirSuccess ' => false ,
139
129
'$resultFileExists ' => true ,
140
130
],
@@ -143,7 +133,6 @@ public function generateDataProvider()
143
133
'$validationSuccess ' => true ,
144
134
'$sourceClassExists ' => true ,
145
135
'$resultClassExists ' => false ,
146
- '$makeGenerationDirSuccess ' => true ,
147
136
'$makeResultDirSuccess ' => true ,
148
137
'$resultFileExists ' => true ,
149
138
'$willWriteCode ' => false ,
@@ -157,7 +146,6 @@ public function generateDataProvider()
157
146
* @param bool $validationSuccess
158
147
* @param bool $sourceClassExists
159
148
* @param bool $resultClassExists
160
- * @param bool $makeGenerationDirSuccess
161
149
* @param bool $makeResultDirSuccess
162
150
* @param bool $resultFileExists
163
151
* @param bool $willWriteCode
@@ -180,7 +168,6 @@ public function testGenerate(
180
168
$ validationSuccess = true ,
181
169
$ sourceClassExists = true ,
182
170
$ resultClassExists = false ,
183
- $ makeGenerationDirSuccess = true ,
184
171
$ makeResultDirSuccess = true ,
185
172
$ resultFileExists = false ,
186
173
$ willWriteCode = true
@@ -191,7 +178,6 @@ public function testGenerate(
191
178
$ arguments = $ this ->_prepareMocksForValidateData (
192
179
$ sourceClassExists ,
193
180
$ resultClassExists ,
194
- $ makeGenerationDirSuccess ,
195
181
$ makeResultDirSuccess ,
196
182
$ resultFileExists
197
183
);
@@ -226,7 +212,6 @@ public function testGenerate(
226
212
*
227
213
* @param bool $sourceClassExists
228
214
* @param bool $resultClassExists
229
- * @param bool $makeGenerationDirSuccess
230
215
* @param bool $makeResultDirSuccess
231
216
* @param bool $resultFileExists
232
217
* @return array
@@ -235,7 +220,6 @@ public function testGenerate(
235
220
protected function _prepareMocksForValidateData (
236
221
$ sourceClassExists = true ,
237
222
$ resultClassExists = false ,
238
- $ makeGenerationDirSuccess = true ,
239
223
$ makeResultDirSuccess = true ,
240
224
$ resultFileExists = false
241
225
) {
@@ -253,31 +237,13 @@ protected function _prepareMocksForValidateData(
253
237
}
254
238
255
239
// Configure IoObject mock
256
- $ ioObject = $ this ->getMock (
257
- 'Magento\Framework\Code\Generator\Io ' ,
258
- [
259
- 'getResultFileName ' ,
260
- 'makeGenerationDirectory ' ,
261
- 'makeResultFileDirectory ' ,
262
- 'fileExists ' ,
263
- 'getGenerationDirectory ' ,
264
- 'getResultFileDirectory ' ,
265
- 'writeResultFile ' ,
266
- 'rename '
267
- ],
268
- [],
269
- '' ,
270
- false
271
- );
240
+ $ ioObject = $ this ->getMockBuilder ('Magento\Framework\Code\Generator\Io ' )
241
+ ->disableOriginalConstructor ()
242
+ ->getMock ();
272
243
273
- $ ioObject ->expects ($ this ->any ())->method ('getGenerationDirectory ' )->willReturn (self ::GENERATION_DIRECTORY );
274
244
$ ioObject ->expects ($ this ->any ())->method ('getResultFileDirectory ' )->willReturn (self ::RESULT_DIRECTORY );
275
- $ makeGenDirInvocations = (!$ sourceClassExists || $ resultClassExists ) ? 0 : 1 ;
276
- $ ioObject ->expects ($ this ->exactly ($ makeGenDirInvocations ))
277
- ->method ('makeGenerationDirectory ' )
278
- ->willReturn ($ makeGenerationDirSuccess );
279
245
$ ioObject ->expects ($ this ->any ())->method ('fileExists ' )->willReturn ($ resultFileExists );
280
- if ($ sourceClassExists && !$ resultClassExists && $ makeGenerationDirSuccess ) {
246
+ if ($ sourceClassExists && !$ resultClassExists ) {
281
247
$ ioObject ->expects ($ this ->once ())
282
248
->method ('makeResultFileDirectory ' )
283
249
->with (self ::RESULT_CLASS )
@@ -304,13 +270,10 @@ protected function _prepareMocksForGenerateCode($willWriteCode)
304
270
// Configure mocks for the validation step
305
271
$ mocks = $ this ->_prepareMocksForValidateData ();
306
272
307
- $ codeGenerator = $ this ->getMock (
308
- 'Magento\Framework\Code\Generator\ClassGenerator ' ,
309
- ['setName ' , 'addProperties ' , 'addMethods ' , 'setClassDocBlock ' , 'generate ' ],
310
- [],
311
- '' ,
312
- false
313
- );
273
+ $ codeGenerator = $ this ->getMockBuilder ('Magento\Framework\Code\Generator\ClassGenerator ' )
274
+ ->disableOriginalConstructor ()
275
+ ->getMock ();
276
+
314
277
$ codeGenerator ->expects ($ this ->once ())->method ('setName ' )->with (self ::RESULT_CLASS )->will ($ this ->returnSelf ());
315
278
$ codeGenerator ->expects ($ this ->once ())->method ('addProperties ' )->will ($ this ->returnSelf ());
316
279
$ codeGenerator ->expects ($ this ->once ())->method ('addMethods ' )->will ($ this ->returnSelf ());
0 commit comments