summaryrefslogtreecommitdiffstats
path: root/tests/lib/User
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-12-20 16:12:51 +0100
committerLukas Reschke <lukas@statuscode.ch>2016-12-23 12:42:31 +0100
commit91cd57e55b034ec3be06c5db8fb2a60bfdf3c749 (patch)
tree554c2eb5b1ed9a0bd953ec0ee6c51d1eca4fffb6 /tests/lib/User
parent91c87d3a7a219101abdb14c096a15587b79e5bea (diff)
downloadnextcloud-server-91cd57e55b034ec3be06c5db8fb2a60bfdf3c749.tar.gz
nextcloud-server-91cd57e55b034ec3be06c5db8fb2a60bfdf3c749.zip
Get user home folder before deletion
After the deletion getHome() will fail because the user doesn't exist any more, so we need to fetch that value earlier. Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests/lib/User')
-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