@@ -133,14 +133,14 @@ public function testHandleConfluenceHtmlFileNotExist()
133
133
$ this ->artisan ('wiki:import ' )
134
134
->expectsQuestion ('数据来源? ' , 'Confluence ' )
135
135
->expectsQuestion ('数据类型? ' , 'HTML ' )
136
- ->expectsQuestion ('空间导出的 HTML 目录 ' , '~/Downloads/ ' )
136
+ ->expectsQuestion ('空间导出的 HTML zip 文件路径 ' , '~/Downloads/ ' )
137
137
->expectsOutput ('文件不存在:~/Downloads/index.html ' )
138
138
->assertExitCode (1 );
139
139
140
140
$ this ->artisan ('wiki:import ' )
141
141
->expectsQuestion ('数据来源? ' , 'Confluence ' )
142
142
->expectsQuestion ('数据类型? ' , 'HTML ' )
143
- ->expectsQuestion ('空间导出的 HTML 目录 ' , '~/Downloads/index.html ' )
143
+ ->expectsQuestion ('空间导出的 HTML zip 文件路径 ' , '~/Downloads/index.html ' )
144
144
->expectsOutput ('文件不存在:~/Downloads/index.html ' )
145
145
->assertExitCode (1 );
146
146
}
@@ -177,7 +177,7 @@ public function testHandleConfluenceHtmlSuccess()
177
177
$ this ->artisan ('wiki:import ' )
178
178
->expectsQuestion ('数据来源? ' , 'Confluence ' )
179
179
->expectsQuestion ('数据类型? ' , 'HTML ' )
180
- ->expectsQuestion ('空间导出的 HTML 目录 ' , $ this ->dataDir . 'confluence/space1/ ' )
180
+ ->expectsQuestion ('空间导出的 HTML zip 文件路径 ' , $ this ->dataDir . 'confluence/space1/ ' )
181
181
->expectsOutput ('空间名称:空间 1 ' )
182
182
->expectsOutput ('空间标识:space1 ' )
183
183
->expectsOutput ('发现 2 个一级页面 ' )
@@ -210,4 +210,59 @@ public function testAskNothing()
210
210
->expectsOutput ('文件不存在:/dev/null/index.html ' )
211
211
->assertExitCode (1 );
212
212
}
213
+
214
+ public function testHandleConfluenceHtmlZipSuccess ()
215
+ {
216
+ $ codingToken = $ this ->faker ->md5 ;
217
+ config (['coding.token ' => $ codingToken ]);
218
+ $ codingTeamDomain = $ this ->faker ->domainWord ;
219
+ config (['coding.team_domain ' => $ codingTeamDomain ]);
220
+ $ codingProjectUri = $ this ->faker ->slug ;
221
+ config (['coding.project_uri ' => $ codingProjectUri ]);
222
+
223
+ // 注意:不能使用 partialMock
224
+ // https://laracasts.com/discuss/channels/testing/this-partialmock-doesnt-call-the-constructor
225
+ $ mock = \Mockery::mock (Wiki::class, [])->makePartial ();
226
+ $ this ->instance (Wiki::class, $ mock );
227
+
228
+ $ mock ->shouldReceive ('createWikiByUploadZip ' )->times (5 )->andReturn (json_decode (
229
+ file_get_contents ($ this ->dataDir . 'coding/ ' . 'CreateWikiByZipResponse.json ' ),
230
+ true
231
+ )['Response ' ]);
232
+ $ mock ->shouldReceive ('getImportJobStatus ' )->times (5 )->andReturn (json_decode (
233
+ file_get_contents ($ this ->dataDir . 'coding/ ' . 'DescribeImportJobStatusResponse.json ' ),
234
+ true
235
+ )['Response ' ]['Data ' ]);
236
+ $ mock ->shouldReceive ('updateWikiTitle ' )->times (5 )->andReturn (true );
237
+
238
+
239
+ $ mockDisk = \Mockery::mock (Disk::class, [])->makePartial ();
240
+ $ this ->instance (Disk::class, $ mockDisk );
241
+ $ mockDisk ->shouldReceive ('uploadAttachments ' )->times (5 )->andReturn ([]);
242
+
243
+ $ this ->artisan ('wiki:import ' )
244
+ ->expectsQuestion ('数据来源? ' , 'Confluence ' )
245
+ ->expectsQuestion ('数据类型? ' , 'HTML ' )
246
+ ->expectsQuestion (
247
+ '空间导出的 HTML zip 文件路径 ' ,
248
+ $ this ->dataDir . 'confluence/Confluence-space-export-231543-81.html.zip '
249
+ )
250
+ ->expectsOutput ('空间名称:空间 1 ' )
251
+ ->expectsOutput ('空间标识:space1 ' )
252
+ ->expectsOutput ('发现 1 个一级页面 ' )
253
+ ->expectsOutput ("开始导入 CODING: " )
254
+ ->expectsOutput ('标题:空间 1 Home ' )
255
+ ->expectsOutput ('上传成功,正在处理,任务 ID:a12353fa-f45b-4af2-83db-666bf9f66615 ' )
256
+ ->expectsOutput ('发现 2 个子页面 ' )
257
+ ->expectsOutput ('标题:hello world ' )
258
+ ->expectsOutput ('上传成功,正在处理,任务 ID:a12353fa-f45b-4af2-83db-666bf9f66615 ' )
259
+ ->expectsOutput ('发现 2 个子页面 ' )
260
+ ->expectsOutput ('标题:hello ' )
261
+ ->expectsOutput ('上传成功,正在处理,任务 ID:a12353fa-f45b-4af2-83db-666bf9f66615 ' )
262
+ ->expectsOutput ('标题:world ' )
263
+ ->expectsOutput ('上传成功,正在处理,任务 ID:a12353fa-f45b-4af2-83db-666bf9f66615 ' )
264
+ ->expectsOutput ('标题:你好世界 ' )
265
+ ->expectsOutput ('上传成功,正在处理,任务 ID:a12353fa-f45b-4af2-83db-666bf9f66615 ' )
266
+ ->assertExitCode (0 );
267
+ }
213
268
}
0 commit comments