summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2015-11-23 14:06:25 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2015-11-24 10:26:36 +0100
commitaeae73b364048ebf3baf8cf6d692ac4f62467e7e (patch)
tree9a4c955c4c2cdd5e55e3ab73e7718a1309a0296b /tests
parentcb69e6c2011d43b2c19e594e89cbe7c737aaef1b (diff)
downloadnextcloud-server-aeae73b364048ebf3baf8cf6d692ac4f62467e7e.tar.gz
nextcloud-server-aeae73b364048ebf3baf8cf6d692ac4f62467e7e.zip
[Sharing 2.0] Removed unused DI stuff
The share manager etc should not care about filtering stuff. They should return what is asked for them.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share20/managertest.php117
1 files changed, 3 insertions, 114 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index 54be9033567..e4d0bfad584 100644
--- a/tests/lib/share20/managertest.php
+++ b/tests/lib/share20/managertest.php
@@ -23,64 +23,39 @@ namespace Test\Share20;
use OC\Share20\Manager;
use OC\Share20\Exception;
-
-use OCP\IUser;
-use OCP\IUserManager;
-use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IAppConfig;
-use OCP\Files\Folder;
-use OCP\Share20\IShareProvider;
+use OC\Share20\IShareProvider;
class ManagerTest extends \Test\TestCase {
/** @var Manager */
protected $manager;
- /** @var IUser */
- protected $user;
-
- /** @var IUserManager */
- protected $userManager;
-
- /** @var IGroupManager */
- protected $groupManager;
-
/** @var ILogger */
protected $logger;
/** @var IAppConfig */
protected $appConfig;
- /** @var Folder */
- protected $userFolder;
-
/** @var IShareProvider */
protected $defaultProvider;
public function setUp() {
- $this->user = $this->getMock('\OCP\IUser');
- $this->userManager = $this->getMock('\OCP\IUserManager');
- $this->groupManager = $this->getMock('\OCP\IGroupManager');
$this->logger = $this->getMock('\OCP\ILogger');
$this->appConfig = $this->getMock('\OCP\IAppConfig');
- $this->userFolder = $this->getMock('\OCP\Files\Folder');
$this->defaultProvider = $this->getMock('\OC\Share20\IShareProvider');
$this->manager = new Manager(
- $this->user,
- $this->userManager,
- $this->groupManager,
$this->logger,
$this->appConfig,
- $this->userFolder,
$this->defaultProvider
);
}
/**
- * @expectedException OC\Share20\Exception\ShareNotFound
+ * @expectedException \OC\Share20\Exception\ShareNotFound
*/
public function testDeleteNoShareId() {
$share = $this->getMock('\OC\Share20\IShare');
@@ -115,12 +90,8 @@ class ManagerTest extends \Test\TestCase {
public function testDelete($shareType, $sharedWith, $sharedWith_string) {
$manager = $this->getMockBuilder('\OC\Share20\Manager')
->setConstructorArgs([
- $this->user,
- $this->userManager,
- $this->groupManager,
$this->logger,
$this->appConfig,
- $this->userFolder,
$this->defaultProvider
])
->setMethods(['getShareById', 'deleteChildren'])
@@ -205,12 +176,8 @@ class ManagerTest extends \Test\TestCase {
public function testDeleteNested() {
$manager = $this->getMockBuilder('\OC\Share20\Manager')
->setConstructorArgs([
- $this->user,
- $this->userManager,
- $this->groupManager,
$this->logger,
$this->appConfig,
- $this->userFolder,
$this->defaultProvider
])
->setMethods(['getShareById'])
@@ -349,12 +316,8 @@ class ManagerTest extends \Test\TestCase {
public function testDeleteChildren() {
$manager = $this->getMockBuilder('\OC\Share20\Manager')
->setConstructorArgs([
- $this->user,
- $this->userManager,
- $this->groupManager,
$this->logger,
$this->appConfig,
- $this->userFolder,
$this->defaultProvider
])
->setMethods(['deleteShare'])
@@ -391,82 +354,8 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($shares, $result);
}
- /**
- * @expectedException OC\Share20\Exception\ShareNotFound
- */
- public function testGetShareByIdNotFoundInBackend() {
- $this->defaultProvider
- ->expects($this->once())
- ->method('getShareById')
- ->with(42)
- ->will($this->throwException(new \OC\Share20\Exception\ShareNotFound()));
-
- $this->manager->getShareById(42);
- }
-
- /**
- * @expectedException OC\Share20\Exception\ShareNotFound
- */
- public function testGetShareByIdNotAuthorized() {
- $otherUser1 = $this->getMock('\OCP\IUser');
- $otherUser2 = $this->getMock('\OCP\IUser');
- $otherUser3 = $this->getMock('\OCP\IUser');
-
+ public function testGetShareById() {
$share = $this->getMock('\OC\Share20\IShare');
- $share
- ->expects($this->once())
- ->method('getSharedWith')
- ->with()
- ->willReturn($otherUser1);
- $share
- ->expects($this->once())
- ->method('getSharedBy')
- ->with()
- ->willReturn($otherUser2);
- $share
- ->expects($this->once())
- ->method('getShareOwner')
- ->with()
- ->willReturn($otherUser3);
-
- $this->defaultProvider
- ->expects($this->once())
- ->method('getShareById')
- ->with(42)
- ->willReturn($share);
-
- $this->manager->getShareById(42);
- }
-
- public function dataGetShareById() {
- return [
- ['getSharedWith'],
- ['getSharedBy'],
- ['getShareOwner'],
- ];
- }
-
- /**
- * @dataProvider dataGetShareById
- */
- public function testGetShareById($currentUserIs) {
- $otherUser1 = $this->getMock('\OCP\IUser');
- $otherUser2 = $this->getMock('\OCP\IUser');
- $otherUser3 = $this->getMock('\OCP\IUser');
-
- $share = $this->getMock('\OC\Share20\IShare');
- $share
- ->method('getSharedWith')
- ->with()
- ->willReturn($currentUserIs === 'getSharedWith' ? $this->user : $otherUser1);
- $share
- ->method('getSharedBy')
- ->with()
- ->willReturn($currentUserIs === 'getSharedBy' ? $this->user : $otherUser2);
- $share
- ->method('getShareOwner')
- ->with()
- ->willReturn($currentUserIs === 'getShareOwner' ? $this->user : $otherUser3);
$this->defaultProvider
->expects($this->once())