Merge pull request #21975 from owncloud/fix_ocs_unit_tests
Fix OCS unit tests after two share merges
This commit is contained in:
commit
476720ada9
2 changed files with 32 additions and 32 deletions
|
@ -488,7 +488,7 @@ class Share20OCS {
|
||||||
return new \OC_OCS_Result(null, 403, 'public upload disabled by the administrator');
|
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");
|
return new \OC_OCS_Result(null, 400, "public upload is only possible for public shared folders");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -806,15 +806,15 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$currentUser = $this->currentUser;
|
$currentUser = $this->currentUser;
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
$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) {
|
||||||
return $share->getPath() === $path &&
|
return $share->getNode() === $path &&
|
||||||
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
||||||
$share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
|
$share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
|
||||||
$share->getSharedBy() === $currentUser &&
|
$share->getSharedBy() === $currentUser &&
|
||||||
$share->getPassword() === null &&
|
$share->getPassword() === null &&
|
||||||
$share->getExpirationDate() === null;
|
$share->getExpirationDate() === null;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->createShare();
|
$result = $ocs->createShare();
|
||||||
|
@ -847,15 +847,15 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$currentUser = $this->currentUser;
|
$currentUser = $this->currentUser;
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
$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) {
|
||||||
return $share->getPath() === $path &&
|
return $share->getNode() === $path &&
|
||||||
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
||||||
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
||||||
$share->getSharedBy() === $currentUser &&
|
$share->getSharedBy() === $currentUser &&
|
||||||
$share->getPassword() === 'password' &&
|
$share->getPassword() === 'password' &&
|
||||||
$share->getExpirationDate() === null;
|
$share->getExpirationDate() === null;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->createShare();
|
$result = $ocs->createShare();
|
||||||
|
@ -888,18 +888,18 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$currentUser = $this->currentUser;
|
$currentUser = $this->currentUser;
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('createShare')->with(
|
$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 = new \DateTime('2000-01-01');
|
||||||
$date->setTime(0,0,0);
|
$date->setTime(0,0,0);
|
||||||
|
|
||||||
return $share->getPath() === $path &&
|
return $share->getNode() === $path &&
|
||||||
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
|
||||||
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
||||||
$share->getSharedBy() === $currentUser &&
|
$share->getSharedBy() === $currentUser &&
|
||||||
$share->getPassword() === null &&
|
$share->getPassword() === null &&
|
||||||
$share->getExpirationDate() == $date;
|
$share->getExpirationDate() == $date;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->createShare();
|
$result = $ocs->createShare();
|
||||||
|
@ -1000,12 +1000,12 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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 &&
|
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
|
||||||
$share->getPassword() === null &&
|
$share->getPassword() === null &&
|
||||||
$share->getExpirationDate() === null;
|
$share->getExpirationDate() === null;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
@ -1023,7 +1023,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setSharedBy($this->currentUser)
|
->setSharedBy($this->currentUser)
|
||||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||||
->setPath($folder);
|
->setNode($folder);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1037,7 +1037,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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 = new \DateTime('2000-01-01');
|
||||||
$date->setTime(0,0,0);
|
$date->setTime(0,0,0);
|
||||||
|
|
||||||
|
@ -1045,7 +1045,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->getPassword() === 'password' &&
|
$share->getPassword() === 'password' &&
|
||||||
$share->getExpirationDate() == $date;
|
$share->getExpirationDate() == $date;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
@ -1063,7 +1063,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setSharedBy($this->currentUser)
|
->setSharedBy($this->currentUser)
|
||||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||||
->setPath($folder);
|
->setNode($folder);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1092,7 +1092,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setSharedBy($this->currentUser)
|
->setSharedBy($this->currentUser)
|
||||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||||
->setPath($folder);
|
->setNode($folder);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1121,7 +1121,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setSharedBy($this->currentUser)
|
->setSharedBy($this->currentUser)
|
||||||
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
|
||||||
->setPath($file);
|
->setNode($file);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1164,12 +1164,12 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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 &&
|
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
|
||||||
$share->getPassword() === 'newpassword' &&
|
$share->getPassword() === 'newpassword' &&
|
||||||
$share->getExpirationDate() === $date;
|
$share->getExpirationDate() === $date;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
@ -1198,7 +1198,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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 = new \DateTime('2010-12-23');
|
||||||
$date->setTime(0,0,0);
|
$date->setTime(0,0,0);
|
||||||
|
|
||||||
|
@ -1206,7 +1206,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->getPassword() === 'password' &&
|
$share->getPassword() === 'password' &&
|
||||||
$share->getExpirationDate() == $date;
|
$share->getExpirationDate() == $date;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
@ -1229,7 +1229,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
->setPassword('password')
|
->setPassword('password')
|
||||||
->setExpirationDate($date)
|
->setExpirationDate($date)
|
||||||
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setPath($folder);
|
->setNode($folder);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1241,12 +1241,12 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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 &&
|
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
|
||||||
$share->getPassword() === 'password' &&
|
$share->getPassword() === 'password' &&
|
||||||
$share->getExpirationDate() === $date;
|
$share->getExpirationDate() === $date;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
@ -1269,7 +1269,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
->setPassword('password')
|
->setPassword('password')
|
||||||
->setExpirationDate($date)
|
->setExpirationDate($date)
|
||||||
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setPath($folder);
|
->setNode($folder);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1281,12 +1281,12 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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 &&
|
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
|
||||||
$share->getPassword() === 'password' &&
|
$share->getPassword() === 'password' &&
|
||||||
$share->getExpirationDate() === $date;
|
$share->getExpirationDate() === $date;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
@ -1309,7 +1309,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
->setPassword('password')
|
->setPassword('password')
|
||||||
->setExpirationDate($date)
|
->setExpirationDate($date)
|
||||||
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setPath($folder);
|
->setNode($folder);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1336,7 +1336,7 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
||||||
->setSharedBy($this->currentUser)
|
->setSharedBy($this->currentUser)
|
||||||
->setShareType(\OCP\Share::SHARE_TYPE_USER)
|
->setShareType(\OCP\Share::SHARE_TYPE_USER)
|
||||||
->setPath($file);
|
->setNode($file);
|
||||||
|
|
||||||
$this->request
|
$this->request
|
||||||
->method('getParam')
|
->method('getParam')
|
||||||
|
@ -1348,10 +1348,10 @@ class Share20OCSTest extends \Test\TestCase {
|
||||||
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
|
||||||
|
|
||||||
$this->shareManager->expects($this->once())->method('updateShare')->with(
|
$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;
|
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL;
|
||||||
})
|
})
|
||||||
);
|
)->will($this->returnArgument(0));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null);
|
$expected = new \OC_OCS_Result(null);
|
||||||
$result = $ocs->updateShare(42);
|
$result = $ocs->updateShare(42);
|
||||||
|
|
Loading…
Reference in a new issue