Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit e66b5a8

Browse files
committed
BUG: refs #236. Fix broken web api upload test (for real this time)
1 parent 2734f40 commit e66b5a8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

modules/api/tests/controllers/ApiCallMethodsTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,10 @@ public function testUpload()
271271
$this->assertEquals($resp->message, 'Invalid policy or itemid');
272272
$this->assertTrue($resp->code != 0);
273273

274+
//now upload using our token
274275
$this->resetAll();
275276
$usersFile = $this->loadData('User', 'default');
276277
$itemsFile = $this->loadData('Item', 'default');
277-
278-
//now upload using our token
279-
$this->resetAll();
280278
$string = '';
281279
$length = 100;
282280
for($i = 0; $i < $length; $i++)
@@ -301,15 +299,16 @@ public function testUpload()
301299
$this->params['itemid'] = $itemsFile[1]->getKey();
302300
$this->request->setMethod('POST');
303301
$resp = $this->_callJsonApi();
304-
305302
$this->_assertStatusOk($resp);
303+
306304
$token = $resp->data->token;
307305
$this->assertTrue(
308306
preg_match('/^'.$usersFile[0]->getKey().'\/'.$itemsFile[1]->getKey().'\/.+\..+$/', $token) > 0,
309307
'Upload token ('.$token.') is not of the form <userid>/<itemid>/*.*');
310308
$this->assertTrue(file_exists(BASE_PATH.'/tmp/misc/'.$token),
311309
'Token placeholder file '.$token.' was not created in the temp dir');
312310

311+
$this->resetAll();
313312
$this->params['method'] = 'midas.upload.perform';
314313
$this->params['uploadtoken'] = $token;
315314
$this->params['filename'] = 'test.txt';
@@ -320,11 +319,10 @@ public function testUpload()
320319

321320
$this->request->setMethod('POST');
322321
$resp = $this->_callJsonApi();
322+
$this->_assertStatusOk($resp);
323323

324324
unlink(BASE_PATH.'/tmp/misc/test.txt');
325325

326-
$this->_assertStatusOk($resp);
327-
328326
$this->assertTrue(file_exists($assetstoreFile), 'File was not written to the assetstore');
329327
$this->assertEquals(filesize($assetstoreFile), $length, 'Assetstore file is the wrong length: '.filesize($assetstoreFile));
330328
$this->assertEquals(md5_file($assetstoreFile), $md5, 'Assetstore file had incorrect checksum');

0 commit comments

Comments
 (0)