@@ -271,12 +271,10 @@ public function testUpload()
271
271
$ this ->assertEquals ($ resp ->message , 'Invalid policy or itemid ' );
272
272
$ this ->assertTrue ($ resp ->code != 0 );
273
273
274
+ //now upload using our token
274
275
$ this ->resetAll ();
275
276
$ usersFile = $ this ->loadData ('User ' , 'default ' );
276
277
$ itemsFile = $ this ->loadData ('Item ' , 'default ' );
277
-
278
- //now upload using our token
279
- $ this ->resetAll ();
280
278
$ string = '' ;
281
279
$ length = 100 ;
282
280
for ($ i = 0 ; $ i < $ length ; $ i ++)
@@ -301,15 +299,16 @@ public function testUpload()
301
299
$ this ->params ['itemid ' ] = $ itemsFile [1 ]->getKey ();
302
300
$ this ->request ->setMethod ('POST ' );
303
301
$ resp = $ this ->_callJsonApi ();
304
-
305
302
$ this ->_assertStatusOk ($ resp );
303
+
306
304
$ token = $ resp ->data ->token ;
307
305
$ this ->assertTrue (
308
306
preg_match ('/^ ' .$ usersFile [0 ]->getKey ().'\/ ' .$ itemsFile [1 ]->getKey ().'\/.+\..+$/ ' , $ token ) > 0 ,
309
307
'Upload token ( ' .$ token .') is not of the form <userid>/<itemid>/*.* ' );
310
308
$ this ->assertTrue (file_exists (BASE_PATH .'/tmp/misc/ ' .$ token ),
311
309
'Token placeholder file ' .$ token .' was not created in the temp dir ' );
312
310
311
+ $ this ->resetAll ();
313
312
$ this ->params ['method ' ] = 'midas.upload.perform ' ;
314
313
$ this ->params ['uploadtoken ' ] = $ token ;
315
314
$ this ->params ['filename ' ] = 'test.txt ' ;
@@ -320,11 +319,10 @@ public function testUpload()
320
319
321
320
$ this ->request ->setMethod ('POST ' );
322
321
$ resp = $ this ->_callJsonApi ();
322
+ $ this ->_assertStatusOk ($ resp );
323
323
324
324
unlink (BASE_PATH .'/tmp/misc/test.txt ' );
325
325
326
- $ this ->_assertStatusOk ($ resp );
327
-
328
326
$ this ->assertTrue (file_exists ($ assetstoreFile ), 'File was not written to the assetstore ' );
329
327
$ this ->assertEquals (filesize ($ assetstoreFile ), $ length , 'Assetstore file is the wrong length: ' .filesize ($ assetstoreFile ));
330
328
$ this ->assertEquals (md5_file ($ assetstoreFile ), $ md5 , 'Assetstore file had incorrect checksum ' );
0 commit comments