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

Commit 92209cf

Browse files
committed
ENH: refs #0352. Add a test for uploading an empty file via simple uploader
1 parent c7a671b commit 92209cf

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

core/controllers/UploadController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ public function saveuploadedAction()
246246
if($this->isTestingEnv())
247247
{
248248
//simulate file upload
249-
$path = BASE_PATH.'/tests/testfiles/search.png';
249+
$path = $this->_getParam('path');
250+
$filename = basename($path);
250251
$file_size = filesize($path);
251-
$filename = 'search.png';
252252
}
253253
else
254254
{

core/tests/controllers/UploadDownloadControllerTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,21 @@ function testSaveuploadedAction()
176176
$this->params = array();
177177
$this->params['parent'] = $userDao->getPublicFolder()->getKey();
178178
$this->params['license'] = 0;
179+
$this->params['path'] = BASE_PATH.'/tests/testfiles/search.png'; //testing mode param
179180
$this->dispatchUrI('/upload/saveuploaded', $userDao);
180181

181182
$search = $this->Item->getItemsFromSearch('search.png', $userDao);
182-
if(empty($search))
183-
{
184-
$this->fail('Unable to find item');
185-
}
183+
$this->assertNotEmpty($search, 'Unable to find uploaded item');
184+
185+
// Test to make sure uploading an empty file works
186+
$this->resetAll();
187+
$this->params['parent'] = $userDao->getPublicFolder()->getKey();
188+
$this->params['license'] = 0;
189+
$this->params['path'] = BASE_PATH.'/tests/testfiles/empty.txt'; //testing mode param
190+
$this->dispatchUrI('/upload/saveuploaded', $userDao);
191+
192+
$search = $this->Item->getItemsFromSearch('empty.txt', $userDao);
193+
$this->assertNotEmpty($search, 'Unable to find empty uploaded item');
186194
}
187195

188196
/**

tests/testfiles/empty.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)