Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
d2110ebb
Unverified
Commit
d2110ebb
authored
8 years ago
by
Roeland Jago Douma
Browse files
Options
Downloads
Patches
Plain Diff
Add Manager unit tests
Signed-off-by:
Roeland Jago Douma
<
roeland@famdouma.nl
>
parent
fc4d0a86
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/Share20/ManagerTest.php
+77
-6
77 additions, 6 deletions
tests/lib/Share20/ManagerTest.php
with
77 additions
and
6 deletions
tests/lib/Share20/ManagerTest.php
+
77
−
6
View file @
d2110ebb
...
@@ -22,6 +22,7 @@ namespace Test\Share20;
...
@@ -22,6 +22,7 @@ namespace Test\Share20;
use
OC\Files\Mount\MoveableMount
;
use
OC\Files\Mount\MoveableMount
;
use
OC\HintException
;
use
OC\HintException
;
use
OC\Share20\DefaultShareProvider
;
use
OCP\Files\File
;
use
OCP\Files\File
;
use
OCP\Files\Folder
;
use
OCP\Files\Folder
;
use
OCP\Files\IRootFolder
;
use
OCP\Files\IRootFolder
;
...
@@ -29,6 +30,7 @@ use OCP\Files\Mount\IMountPoint;
...
@@ -29,6 +30,7 @@ use OCP\Files\Mount\IMountPoint;
use
OCP\Files\Node
;
use
OCP\Files\Node
;
use
OCP\Files\Storage
;
use
OCP\Files\Storage
;
use
OCP\IGroup
;
use
OCP\IGroup
;
use
OCP\IServerContainer
;
use
OCP\IUser
;
use
OCP\IUser
;
use
OCP\IUserManager
;
use
OCP\IUserManager
;
use
OCP\Share\Exceptions\ShareNotFound
;
use
OCP\Share\Exceptions\ShareNotFound
;
...
@@ -118,13 +120,9 @@ class ManagerTest extends \Test\TestCase {
...
@@ -118,13 +120,9 @@ class ManagerTest extends \Test\TestCase {
$this
->
eventDispatcher
$this
->
eventDispatcher
);
);
$this
->
defaultProvider
=
$this
->
getMockBuilder
(
'\OC\Share20\DefaultShareProvider'
)
$this
->
defaultProvider
=
$this
->
createMock
(
DefaultShareProvider
::
class
);
->
disableOriginalConstructor
()
->
getMock
();
$this
->
defaultProvider
->
method
(
'identifier'
)
->
willReturn
(
'default'
);
$this
->
defaultProvider
->
method
(
'identifier'
)
->
willReturn
(
'default'
);
$this
->
factory
->
setProvider
(
$this
->
defaultProvider
);
$this
->
factory
->
setProvider
(
$this
->
defaultProvider
);
}
}
/**
/**
...
@@ -2531,12 +2529,71 @@ class ManagerTest extends \Test\TestCase {
...
@@ -2531,12 +2529,71 @@ class ManagerTest extends \Test\TestCase {
$this
->
manager
->
moveShare
(
$share
,
'recipient'
);
$this
->
manager
->
moveShare
(
$share
,
'recipient'
);
}
}
public
function
testGetSharesInFolder
()
{
$factory
=
new
DummyFactory2
(
$this
->
createMock
(
IServerContainer
::
class
));
$manager
=
new
Manager
(
$this
->
logger
,
$this
->
config
,
$this
->
secureRandom
,
$this
->
hasher
,
$this
->
mountManager
,
$this
->
groupManager
,
$this
->
l
,
$factory
,
$this
->
userManager
,
$this
->
rootFolder
,
$this
->
eventDispatcher
);
$factory
->
setProvider
(
$this
->
defaultProvider
);
$extraProvider
=
$this
->
createMock
(
IShareProvider
::
class
);
$factory
->
setSecondProvider
(
$extraProvider
);
$share1
=
$this
->
createMock
(
IShare
::
class
);
$share2
=
$this
->
createMock
(
IShare
::
class
);
$share3
=
$this
->
createMock
(
IShare
::
class
);
$share4
=
$this
->
createMock
(
IShare
::
class
);
$folder
=
$this
->
createMock
(
Folder
::
class
);
$this
->
defaultProvider
->
method
(
'getSharesInFolder'
)
->
with
(
$this
->
equalTo
(
'user'
),
$this
->
equalTo
(
$folder
),
$this
->
equalTo
(
false
)
)
->
willReturn
([
1
=>
[
$share1
],
2
=>
[
$share2
],
]);
$extraProvider
->
method
(
'getSharesInFolder'
)
->
with
(
$this
->
equalTo
(
'user'
),
$this
->
equalTo
(
$folder
),
$this
->
equalTo
(
false
)
)
->
willReturn
([
2
=>
[
$share3
],
3
=>
[
$share4
],
]);
$result
=
$manager
->
getSharesInFolder
(
'user'
,
$folder
,
false
);
$expects
=
[
1
=>
[
$share1
],
2
=>
[
$share2
,
$share3
],
3
=>
[
$share4
],
];
$this
->
assertSame
(
$expects
,
$result
);
}
}
}
class
DummyFactory
implements
IProviderFactory
{
class
DummyFactory
implements
IProviderFactory
{
/** @var IShareProvider */
/** @var IShareProvider */
pr
ivate
$provider
;
pr
otected
$provider
;
public
function
__construct
(
\OCP\IServerContainer
$serverContainer
)
{
public
function
__construct
(
\OCP\IServerContainer
$serverContainer
)
{
...
@@ -2571,6 +2628,20 @@ class DummyFactory implements IProviderFactory {
...
@@ -2571,6 +2628,20 @@ class DummyFactory implements IProviderFactory {
public
function
getAllProviders
()
{
public
function
getAllProviders
()
{
return
[
$this
->
provider
];
return
[
$this
->
provider
];
}
}
}
class
DummyFactory2
extends
DummyFactory
{
/** @var IShareProvider */
private
$provider2
;
/**
* @param IShareProvider $provider
*/
public
function
setSecondProvider
(
$provider
)
{
$this
->
provider2
=
$provider
;
}
public
function
getAllProviders
()
{
return
[
$this
->
provider
,
$this
->
provider2
];
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment