Skip to content

Commit

Permalink
Merge pull request #21975 from owncloud/fix_ocs_unit_tests
Browse files Browse the repository at this point in the history
Fix OCS unit tests after two share merges
  • Loading branch information
DeepDiver1975 committed Jan 28, 2016
2 parents de8852a + 2831884 commit 476720a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion apps/files_sharing/api/share20ocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public function updateShare($id) {
return new \OC_OCS_Result(null, 403, 'public upload disabled by the administrator');
}

if (!($share->getPath() instanceof \OCP\Files\Folder)) {
if (!($share->getNode() instanceof \OCP\Files\Folder)) {
return new \OC_OCS_Result(null, 400, "public upload is only possible for public shared folders");
}
}
Expand Down
62 changes: 31 additions & 31 deletions apps/files_sharing/tests/api/share20ocstest.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,15 +806,15 @@ public function testCreateShareLinkPublicUploadFolder() {
$currentUser = $this->currentUser;

$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (IShare $share) use ($path, $currentUser) {
return $share->getPath() === $path &&
$this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
return $share->getNode() === $path &&
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
$share->getSharedBy() === $currentUser &&
$share->getPassword() === null &&
$share->getExpirationDate() === null;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->createShare();
Expand Down Expand Up @@ -847,15 +847,15 @@ public function testCreateShareLinkPassword() {
$currentUser = $this->currentUser;

$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (IShare $share) use ($path, $currentUser) {
return $share->getPath() === $path &&
$this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
return $share->getNode() === $path &&
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getSharedBy() === $currentUser &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() === null;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->createShare();
Expand Down Expand Up @@ -888,18 +888,18 @@ public function testCreateShareValidExpireDate() {
$currentUser = $this->currentUser;

$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (IShare $share) use ($path, $currentUser) {
$this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
$date = new \DateTime('2000-01-01');
$date->setTime(0,0,0);

return $share->getPath() === $path &&
return $share->getNode() === $path &&
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getSharedBy() === $currentUser &&
$share->getPassword() === null &&
$share->getExpirationDate() == $date;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->createShare();
Expand Down Expand Up @@ -1000,12 +1000,12 @@ public function testUpdateLinkShareClear() {
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) {
$this->callback(function (\OCP\Share\IShare $share) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getPassword() === null &&
$share->getExpirationDate() === null;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand All @@ -1023,7 +1023,7 @@ public function testUpdateLinkShareSet() {
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPath($folder);
->setNode($folder);

$this->request
->method('getParam')
Expand All @@ -1037,15 +1037,15 @@ public function testUpdateLinkShareSet() {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) {
$this->callback(function (\OCP\Share\IShare $share) {
$date = new \DateTime('2000-01-01');
$date->setTime(0,0,0);

return $share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE && \OCP\Constants::PERMISSION_DELETE &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() == $date;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand All @@ -1063,7 +1063,7 @@ public function testUpdateLinkShareInvalidDate() {
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPath($folder);
->setNode($folder);

$this->request
->method('getParam')
Expand Down Expand Up @@ -1092,7 +1092,7 @@ public function testUpdateLinkSharePublicUploadNotAllowed() {
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPath($folder);
->setNode($folder);

$this->request
->method('getParam')
Expand Down Expand Up @@ -1121,7 +1121,7 @@ public function testUpdateLinkSharePublicUploadOnFile() {
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPath($file);
->setNode($file);

$this->request
->method('getParam')
Expand Down Expand Up @@ -1164,12 +1164,12 @@ public function testUpdateLinkSharePasswordDoesNotChangeOther() {
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) use ($date) {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
$share->getPassword() === 'newpassword' &&
$share->getExpirationDate() === $date;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand Down Expand Up @@ -1198,15 +1198,15 @@ public function testUpdateLinkShareExpireDateDoesNotChangeOther() {
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) {
$this->callback(function (\OCP\Share\IShare $share) {
$date = new \DateTime('2010-12-23');
$date->setTime(0,0,0);

return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() == $date;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand All @@ -1229,7 +1229,7 @@ public function testUpdateLinkSharePublicUploadDoesNotChangeOther() {
->setPassword('password')
->setExpirationDate($date)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPath($folder);
->setNode($folder);

$this->request
->method('getParam')
Expand All @@ -1241,12 +1241,12 @@ public function testUpdateLinkSharePublicUploadDoesNotChangeOther() {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) use ($date) {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() === $date;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand All @@ -1269,7 +1269,7 @@ public function testUpdateLinkSharePermissions() {
->setPassword('password')
->setExpirationDate($date)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPath($folder);
->setNode($folder);

$this->request
->method('getParam')
Expand All @@ -1281,12 +1281,12 @@ public function testUpdateLinkSharePermissions() {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) use ($date) {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() === $date;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand All @@ -1309,7 +1309,7 @@ public function testUpdateLinkShareInvalidPermissions() {
->setPassword('password')
->setExpirationDate($date)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPath($folder);
->setNode($folder);

$this->request
->method('getParam')
Expand All @@ -1336,7 +1336,7 @@ public function testUpdateOtherPermissions() {
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setPath($file);
->setNode($file);

$this->request
->method('getParam')
Expand All @@ -1348,10 +1348,10 @@ public function testUpdateOtherPermissions() {
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);

$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) {
$this->callback(function (\OCP\Share\IShare $share) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL;
})
);
)->will($this->returnArgument(0));

$expected = new \OC_OCS_Result(null);
$result = $ocs->updateShare(42);
Expand Down

0 comments on commit 476720a

Please sign in to comment.