- adding unit test testGetShareFromUnknownId()
- fixing getShareFromId() for Oracle - fixing error message
This commit is contained in:
parent
5b4f515e7b
commit
63ea6844e8
|
@ -86,7 +86,7 @@ class Api {
|
|||
}
|
||||
|
||||
if ($shares === null || empty($shares)) {
|
||||
return new \OC_OCS_Result(null, 404, 'share doesn\'t exists');
|
||||
return new \OC_OCS_Result(null, 404, 'share doesn\'t exist');
|
||||
} else {
|
||||
return new \OC_OCS_Result($shares);
|
||||
}
|
||||
|
@ -451,17 +451,15 @@ class Api {
|
|||
$query = \OCP\DB::prepare($sql);
|
||||
$result = $query->execute($args);
|
||||
|
||||
$share = Null;
|
||||
|
||||
if (\OCP\DB::isError($result)) {
|
||||
\OCP\Util::writeLog('files_sharing', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
|
||||
} else {
|
||||
if ($result->numRows() > 0) {
|
||||
$share = $result->fetchRow();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if ($share = $result->fetchRow()) {
|
||||
return $share;
|
||||
}
|
||||
|
||||
return $share;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
|
|||
$fileInfo = $this->view->getFileInfo($this->filename);
|
||||
|
||||
$result = \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
|
||||
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
|
||||
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
|
||||
|
||||
// share was successful?
|
||||
$this->assertTrue($result);
|
||||
|
@ -239,11 +239,25 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$this->assertTrue($result->succeeded());
|
||||
|
||||
// test should return one share created from testCreateShare()
|
||||
// test should return one share created from testCreateShare()
|
||||
$this->assertEquals(count($result->getData()), 1);
|
||||
|
||||
\OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
|
||||
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
|
||||
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @medium
|
||||
*/
|
||||
function testGetShareFromUnknownId() {
|
||||
|
||||
$params = array('id' => 0);
|
||||
|
||||
$result = Share\Api::getShare($params);
|
||||
|
||||
$this->assertEquals(404, $result->getStatusCode());
|
||||
$this->assertEquals('share doesn\'t exist', $result->getMeta()['message']);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue