summaryrefslogtreecommitdiffstats
path: root/tests/lib/User/UserTest.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-12-27 13:45:28 +0100
committerGitHub <noreply@github.com>2016-12-27 13:45:28 +0100
commitf237c582ba5232d0b73c2a2a0cb15101f06697d0 (patch)
tree296ef7e6ad455248d279556b3481210cd10acf53 /tests/lib/User/UserTest.php
parentbd20139f55bbf4871024579994c687d105df3e9c (diff)
parent91cd57e55b034ec3be06c5db8fb2a60bfdf3c749 (diff)
downloadnextcloud-server-f237c582ba5232d0b73c2a2a0cb15101f06697d0.tar.gz
nextcloud-server-f237c582ba5232d0b73c2a2a0cb15101f06697d0.zip
Merge pull request #2845 from nextcloud/deleteuser-gethomeearly
Get user home folder before deletion
Diffstat (limited to 'tests/lib/User/UserTest.php')
-rw-r--r--tests/lib/User/UserTest.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index 734e86c187b..edb8ac4224e 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -200,6 +200,38 @@ class UserTest extends TestCase {
$this->assertTrue($user->delete());
}
+ public function testDeleteWithDifferentHome() {
+ /**
+ * @var Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ */
+ $backend = $this->createMock(Dummy::class);
+
+ $backend->expects($this->at(0))
+ ->method('implementsActions')
+ ->will($this->returnCallback(function ($actions) {
+ if ($actions === Backend::GET_HOME) {
+ return true;
+ } else {
+ return false;
+ }
+ }));
+
+ // important: getHome MUST be called before deleteUser because
+ // once the user is deleted, getHome implementations might not
+ // return anything
+ $backend->expects($this->at(1))
+ ->method('getHome')
+ ->with($this->equalTo('foo'))
+ ->will($this->returnValue('/home/foo'));
+
+ $backend->expects($this->at(2))
+ ->method('deleteUser')
+ ->with($this->equalTo('foo'));
+
+ $user = new User('foo', $backend);
+ $this->assertTrue($user->delete());
+ }
+
public function testGetHome() {
/**
* @var Backend | \PHPUnit_Framework_MockObject_MockObject $backend