@@ -43,4 +43,36 @@ public function testCreateWiki()
43
43
$ result = $ coding ->createWiki ($ codingToken , $ codingProjectUri , $ article );
44
44
$ this ->assertEquals (json_decode ($ responseBody , true )['Response ' ]['Data ' ], $ result );
45
45
}
46
+
47
+ public function testCreateUploadToken ()
48
+ {
49
+ $ responseBody = file_get_contents ($ this ->dataDir . 'coding/createUploadTokenResponse.json ' );
50
+ $ codingToken = $ this ->faker ->md5 ;
51
+ $ codingProjectUri = $ this ->faker ->slug ;
52
+ $ fileName = $ this ->faker ->word ;
53
+
54
+ $ clientMock = $ this ->getMockBuilder (Client::class)->getMock ();
55
+ $ clientMock ->expects ($ this ->once ())
56
+ ->method ('request ' )
57
+ ->with (
58
+ 'POST ' ,
59
+ 'https://e.coding.net/open-api ' ,
60
+ [
61
+ 'headers ' => [
62
+ 'Accept ' => 'application/json ' ,
63
+ 'Authorization ' => "token $ {codingToken}" ,
64
+ 'Content-Type ' => 'application/json '
65
+ ],
66
+ 'json ' => [
67
+ 'Action ' => 'CreateWiki ' ,
68
+ 'ProjectName ' => $ codingProjectUri ,
69
+ 'FileName ' => $ fileName ,
70
+ ],
71
+ ]
72
+ )
73
+ ->willReturn (new Response (200 , [], $ responseBody ));
74
+ $ coding = new Coding ($ clientMock );
75
+ $ result = $ coding ->createUploadToken ($ codingToken , $ codingProjectUri , $ fileName );
76
+ $ this ->assertEquals (json_decode ($ responseBody , true )['Response ' ]['Token ' ], $ result );
77
+ }
46
78
}
0 commit comments