[Pkg-owncloud-commits] [owncloud] 58/103: Add tests for the correct share id on the call aswell
David Prévot
taffit at moszumanska.debian.org
Sun May 31 12:32:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v8.0.4RC1
in repository owncloud.
commit 5733878d6657c6e02ba3ded9e7eab4a9ba3dafe3
Author: Joas Schilling <nickvergessen at owncloud.com>
Date: Tue Apr 28 14:56:13 2015 +0200
Add tests for the correct share id on the call aswell
---
apps/files_sharing/tests/external/managertest.php | 18 +++++++++++++++---
tests/lib/share/share.php | 13 ++++++++-----
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/apps/files_sharing/tests/external/managertest.php b/apps/files_sharing/tests/external/managertest.php
index 3a88c78..33a6465 100644
--- a/apps/files_sharing/tests/external/managertest.php
+++ b/apps/files_sharing/tests/external/managertest.php
@@ -56,9 +56,6 @@ class ManagerTest extends TestCase {
}
public function testAddShare() {
- $this->httpHelper->expects($this->exactly(4))
- ->method('post')
- ->with($this->stringStartsWith('http://localhost/ocs/v1.php/cloud/shares'), $this->anything());
$shareData1 = [
'remote' => 'http://localhost',
@@ -97,6 +94,10 @@ class ManagerTest extends TestCase {
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
+ $this->httpHelper->expects($this->at(0))
+ ->method('post')
+ ->with($this->stringStartsWith('http://localhost/ocs/v1.php/cloud/shares/' . $openShares[0]['remote_id']), $this->anything());
+
// Accept the first share
$this->manager->acceptShare($openShares[0]['id']);
@@ -128,6 +129,10 @@ class ManagerTest extends TestCase {
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
+ $this->httpHelper->expects($this->at(0))
+ ->method('post')
+ ->with($this->stringStartsWith('http://localhost/ocs/v1.php/cloud/shares/' . $openShares[1]['remote_id'] . '/decline'), $this->anything());
+
// Decline the third share
$this->manager->declineShare($openShares[1]['id']);
@@ -151,6 +156,13 @@ class ManagerTest extends TestCase {
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
$this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
+ $this->httpHelper->expects($this->at(0))
+ ->method('post')
+ ->with($this->stringStartsWith('http://localhost/ocs/v1.php/cloud/shares/' . $openShares[0]['remote_id'] . '/decline'), $this->anything());
+ $this->httpHelper->expects($this->at(1))
+ ->method('post')
+ ->with($this->stringStartsWith('http://localhost/ocs/v1.php/cloud/shares/' . $acceptedShares[0]['remote_id'] . '/decline'), $this->anything());
+
$this->manager->removeUserShares($this->uid);
$this->assertEmpty(\Test_Helper::invokePrivate($this->manager, 'getShares', [null]), 'Asserting all shares for the user have been deleted');
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index f96e5d3..8f3d927 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -1052,16 +1052,19 @@ class Test_Share extends \Test\TestCase {
->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]);
- $httpHelperMock->expects($this->at(2))
+ \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith, \OCP\Constants::PERMISSION_READ);
+ $shares = \OCP\Share::getItemShared('test', 'test.txt');
+ $share = array_shift($shares);
+
+ $httpHelperMock->expects($this->at(0))
->method('post')
- ->with($this->stringStartsWith('https://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
+ ->with($this->stringStartsWith('https://' . $urlHost . '/ocs/v1.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything())
->willReturn(['success' => false, 'result' => 'Exception']);
- $httpHelperMock->expects($this->at(3))
+ $httpHelperMock->expects($this->at(1))
->method('post')
- ->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v1.php/cloud/shares'), $this->anything())
+ ->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v1.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything())
->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]);
- \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith, \OCP\Constants::PERMISSION_READ);
\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith);
$this->setHttpHelper($oldHttpHelper);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list