@@ -262,6 +262,7 @@ public function testUpload()
262
262
$ this ->params ['token ' ] = $ this ->_loginUsingApiKey ();
263
263
$ this ->params ['method ' ] = 'midas.upload.generatetoken ' ;
264
264
$ this ->params ['filename ' ] = 'test.txt ' ;
265
+ $ this ->params ['checksum ' ] = 'foo ' ;
265
266
// call should fail for the first item since we don't have write permission
266
267
$ this ->params ['itemid ' ] = $ itemsFile [0 ]->getKey ();
267
268
$ this ->request ->setMethod ('POST ' );
@@ -274,9 +275,25 @@ public function testUpload()
274
275
$ usersFile = $ this ->loadData ('User ' , 'default ' );
275
276
$ itemsFile = $ this ->loadData ('Item ' , 'default ' );
276
277
278
+ //now upload using our token
279
+ $ this ->resetAll ();
280
+ $ string = '' ;
281
+ $ length = 100 ;
282
+ for ($ i = 0 ; $ i < $ length ; $ i ++)
283
+ {
284
+ $ string .= 'a ' ;
285
+ }
286
+ $ fh = fopen (BASE_PATH .'/tmp/misc/test.txt ' , 'w ' );
287
+ fwrite ($ fh , $ string );
288
+ fclose ($ fh );
289
+ $ md5 = md5 ($ string );
290
+ $ assetstoreFile = BASE_PATH .'/data/assetstore/ ' .substr ($ md5 , 0 , 2 ).'/ ' .substr ($ md5 , 2 , 2 ).'/ ' .$ md5 ;
291
+ unlink ($ assetstoreFile );
292
+
277
293
$ this ->params ['token ' ] = $ this ->_loginUsingApiKey ();
278
294
$ this ->params ['method ' ] = 'midas.upload.generatetoken ' ;
279
295
$ this ->params ['filename ' ] = 'test.txt ' ;
296
+ $ this ->params ['checksum ' ] = $ md5 ;
280
297
// use the second item since it has write permission set for our user
281
298
$ this ->params ['itemid ' ] = $ itemsFile [1 ]->getKey ();
282
299
$ this ->request ->setMethod ('POST ' );
@@ -290,22 +307,6 @@ public function testUpload()
290
307
$ this ->assertTrue (file_exists (BASE_PATH .'/tmp/misc/ ' .$ token ),
291
308
'Token placeholder file ' .$ token .' was not created in the temp dir ' );
292
309
293
- //now upload using our token
294
- $ this ->resetAll ();
295
-
296
- $ string = '' ;
297
- $ length = 100 ;
298
- for ($ i = 0 ; $ i < $ length ; $ i ++)
299
- {
300
- $ string .= 'a ' ;
301
- }
302
- $ fh = fopen (BASE_PATH .'/tmp/misc/test.txt ' , 'w ' );
303
- fwrite ($ fh , $ string );
304
- fclose ($ fh );
305
- $ md5 = md5 ($ string );
306
- $ assetstoreFile = BASE_PATH .'/data/assetstore/ ' .substr ($ md5 , 0 , 2 ).'/ ' .substr ($ md5 , 2 , 2 ).'/ ' .$ md5 ;
307
- unlink ($ assetstoreFile );
308
-
309
310
$ this ->params ['method ' ] = 'midas.upload.perform ' ;
310
311
$ this ->params ['uploadtoken ' ] = $ token ;
311
312
$ this ->params ['filename ' ] = 'test.txt ' ;
0 commit comments