2013-10-28 23:14:23 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2024-05-10 13:09:14 +00:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2013-10-28 23:14:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\Files\Storage;
|
|
|
|
|
|
|
|
use OC\User\User;
|
|
|
|
|
|
|
|
class DummyUser extends User {
|
|
|
|
private $home;
|
|
|
|
|
|
|
|
private $uid;
|
|
|
|
|
2014-02-19 08:31:54 +00:00
|
|
|
/**
|
|
|
|
* @param string $uid
|
|
|
|
* @param string $home
|
|
|
|
*/
|
2013-10-28 23:14:23 +00:00
|
|
|
public function __construct($uid, $home) {
|
|
|
|
$this->uid = $uid;
|
|
|
|
$this->home = $home;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHome() {
|
|
|
|
return $this->home;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUID() {
|
|
|
|
return $this->uid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-20 10:27:11 +00:00
|
|
|
/**
|
|
|
|
* Class Home
|
|
|
|
*
|
|
|
|
* @group DB
|
|
|
|
*
|
|
|
|
* @package Test\Files\Storage
|
|
|
|
*/
|
2016-05-20 13:38:20 +00:00
|
|
|
class HomeTest extends Storage {
|
2013-10-28 23:14:23 +00:00
|
|
|
/**
|
|
|
|
* @var string tmpDir
|
|
|
|
*/
|
|
|
|
private $tmpDir;
|
|
|
|
|
2014-07-22 14:30:25 +00:00
|
|
|
private $userId;
|
|
|
|
|
2013-10-28 23:14:23 +00:00
|
|
|
/**
|
|
|
|
* @var \OC\User\User $user
|
|
|
|
*/
|
|
|
|
private $user;
|
|
|
|
|
2019-11-21 15:40:38 +00:00
|
|
|
protected function setUp(): void {
|
2014-11-07 14:23:15 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
2015-12-18 10:19:53 +00:00
|
|
|
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
|
2014-11-07 14:23:15 +00:00
|
|
|
$this->userId = $this->getUniqueID('user_');
|
2013-11-12 14:46:01 +00:00
|
|
|
$this->user = new DummyUser($this->userId, $this->tmpDir);
|
2020-03-26 08:30:18 +00:00
|
|
|
$this->instance = new \OC\Files\Storage\Home(['user' => $this->user]);
|
2013-10-28 23:14:23 +00:00
|
|
|
}
|
|
|
|
|
2019-11-21 15:40:38 +00:00
|
|
|
protected function tearDown(): void {
|
2013-10-28 23:14:23 +00:00
|
|
|
\OC_Helper::rmdirr($this->tmpDir);
|
2014-11-07 14:23:15 +00:00
|
|
|
parent::tearDown();
|
2013-10-28 23:14:23 +00:00
|
|
|
}
|
|
|
|
|
2013-11-12 14:46:01 +00:00
|
|
|
/**
|
|
|
|
* Tests that the home id is in the format home::user1
|
|
|
|
*/
|
|
|
|
public function testId(): void {
|
|
|
|
$this->assertEquals('home::' . $this->userId, $this->instance->getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that getCache() returns an instance of HomeCache
|
|
|
|
*/
|
|
|
|
public function testGetCacheReturnsHomeCache(): void {
|
|
|
|
$this->assertInstanceOf('\OC\Files\Cache\HomeCache', $this->instance->getCache());
|
|
|
|
}
|
2014-07-22 14:30:25 +00:00
|
|
|
|
|
|
|
public function testGetOwner(): void {
|
|
|
|
$this->assertEquals($this->userId, $this->instance->getOwner(''));
|
|
|
|
}
|
2013-10-28 23:14:23 +00:00
|
|
|
}
|