Add tests for the correct share id on the call aswell
This commit is contained in:
parent
34181c3aef
commit
b55ef51a27
2 changed files with 23 additions and 8 deletions
|
@ -55,9 +55,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',
|
||||
|
@ -96,6 +93,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']);
|
||||
|
||||
|
@ -127,6 +128,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']);
|
||||
|
||||
|
@ -150,6 +155,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');
|
||||
|
||||
|
|
|
@ -1061,16 +1061,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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue