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

Commit

Permalink
BUG: refs #0358. Fix folder.create api method and add a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmullen committed Nov 17, 2011
1 parent 0ce2b2d commit f0a7801
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/api/controllers/components/ApiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function folderCreate($args)
$modelLoader = new MIDAS_ModelLoader();
$folderModel = $modelLoader->loadModel('Folder');
$name = $args['name'];
$description = $args['description'];
$description = isset($args['description']) ? $args['description'] : '';

$uuid = isset($args['uuid']) ? $args['uuid'] : '';
$record = false;
Expand Down Expand Up @@ -720,7 +720,7 @@ function folderCreate($args)
$policyGroup = $folder->getFolderpolicygroup();
$policyUser = $folder->getFolderpolicyuser();
$folderpolicygroupModel = $modelLoader->loadModel('Folderpolicygroup');
$folderpolicyuserModel = $modelLoader->loadModel('Folderpolicygroup');
$folderpolicyuserModel = $modelLoader->loadModel('Folderpolicyuser');
foreach($policyGroup as $policy)
{
$folderpolicygroupModel->createPolicy($policy->getGroup(), $new_folder, $policy->getPolicy());
Expand Down
21 changes: 21 additions & 0 deletions modules/api/tests/controllers/ApiCallMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ public function testCommunityList()
//TODO test that a private community is not returned (requires another community in the data set)
}

/** Test creating a folder */
public function testFolderCreate()
{
$usersFile = $this->loadData('User', 'default');
$userDao = $this->User->load($usersFile[0]->getKey());

$this->resetAll();
$this->params['token'] = $this->_loginAsAdministrator();
$this->params['method'] = 'midas.folder.create';
$this->params['name'] = 'testFolderCreate';
$this->params['parentid'] = $userDao->getPublicfolderId();
$resp = $this->_callJsonApi();
$this->_assertStatusOk($resp);

// Make sure folder was created correctly
$this->assertNotEmpty($resp->data->uuid);
$this->assertEquals($userDao->getPublicfolderId(), $resp->data->parent_id);
$this->assertEquals('testFolderCreate', $resp->data->name);
$this->assertEquals('', $resp->data->description);
}

/** Test listing of child folders */
public function testFolderChildren()
{
Expand Down

0 comments on commit f0a7801

Please sign in to comment.