aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-09-13 09:26:00 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-09-13 09:40:59 +0200
commit56d37e27bc543a1f7710cdde231891ee5a31926a (patch)
tree86290e5bd1ef74596a1f416ad5c106d2c06c1a63 /apps
parentfb52b1af67320e221fc66c13b32f98e5d5438229 (diff)
downloadnextcloud-server-56d37e27bc543a1f7710cdde231891ee5a31926a.tar.gz
nextcloud-server-56d37e27bc543a1f7710cdde231891ee5a31926a.zip
Fix tests
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/tests/API/Share20OCSTest.php40
1 files changed, 17 insertions, 23 deletions
diff --git a/apps/files_sharing/tests/API/Share20OCSTest.php b/apps/files_sharing/tests/API/Share20OCSTest.php
index 2621c890b37..f9579b89935 100644
--- a/apps/files_sharing/tests/API/Share20OCSTest.php
+++ b/apps/files_sharing/tests/API/Share20OCSTest.php
@@ -24,6 +24,8 @@
namespace OCA\Files_Sharing\Tests\API;
use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCS\OCSNotFoundException;
+use OCP\Files\Folder;
use OCP\IL10N;
use OCA\Files_Sharing\API\Share20OCS;
use OCP\Files\NotFoundException;
@@ -108,8 +110,11 @@ class Share20OCSTest extends \Test\TestCase {
);
}
+ /**
+ * @return Share20OCS|\PHPUnit_Framework_MockObject_MockObject
+ */
private function mockFormatShare() {
- return $this->getMockBuilder('OCA\Files_Sharing\API\Share20OCS')
+ return $this->getMockBuilder(Share20OCS::class)
->setConstructorArgs([
$this->appName,
$this->request,
@@ -1572,9 +1577,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateShareCannotIncreasePermissions() {
$ocs = $this->mockFormatShare();
- $date = new \DateTime('2000-01-01');
-
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->createMock(Folder::class);
$share = \OC::$server->getShareManager()->newShare();
$share
@@ -1615,19 +1618,18 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->expects($this->never())->method('updateShare');
- $expected = new \OC_OCS_Result(null, 404, 'Cannot increase permissions');
- $result = $ocs->updateShare(42);
-
- $this->assertEquals($expected->getMeta(), $result->getMeta());
- $this->assertEquals($expected->getData(), $result->getData());
+ try {
+ $ocs->updateShare(42, 31);
+ $this->fail();
+ } catch (OCSNotFoundException $e) {
+ $this->assertEquals('Cannot increase permissions', $e->getMessage());
+ }
}
public function testUpdateShareCanIncreasePermissionsIfOwner() {
$ocs = $this->mockFormatShare();
- $date = new \DateTime('2000-01-01');
-
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->createMock(Folder::class);
$share = \OC::$server->getShareManager()->newShare();
$share
@@ -1651,12 +1653,6 @@ class Share20OCSTest extends \Test\TestCase {
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['permissions', null, '31'],
- ]));
-
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$this->shareManager->expects($this->any(0))
@@ -1671,12 +1667,10 @@ class Share20OCSTest extends \Test\TestCase {
->with($share)
->willReturn($share);
- $expected = new \OC_OCS_Result();
- $result = $ocs->updateShare(42);
-
- $this->assertEquals($expected->getMeta(), $result->getMeta());
- $this->assertEquals($expected->getData(), $result->getData());
+ $result = $ocs->updateShare(42, 31);
+ $this->assertInstanceOf(DataResponse::class, $result);
}
+
public function dataFormatShare() {
$file = $this->getMockBuilder('\OCP\Files\File')->getMock();
$folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();