2016-11-16 11:07:26 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2024-05-10 15:09:14 +02:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-11-16 11:07:26 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\Files;
|
|
|
|
|
|
|
|
use OC\Files\FileInfo;
|
2023-10-23 13:22:23 +02:00
|
|
|
use OC\Files\Mount\HomeMountPoint;
|
|
|
|
use OC\Files\Mount\MountPoint;
|
2016-11-16 11:07:26 +01:00
|
|
|
use OC\Files\Storage\Home;
|
|
|
|
use OC\Files\Storage\Temporary;
|
|
|
|
use OCP\IConfig;
|
2019-02-22 13:07:26 +01:00
|
|
|
use OCP\IUser;
|
2016-11-16 11:07:26 +01:00
|
|
|
use Test\TestCase;
|
|
|
|
use Test\Traits\UserTrait;
|
|
|
|
|
|
|
|
class FileInfoTest extends TestCase {
|
|
|
|
use UserTrait;
|
|
|
|
|
|
|
|
private $config;
|
|
|
|
|
2019-11-27 15:27:18 +01:00
|
|
|
protected function setUp(): void {
|
2016-11-16 11:07:26 +01:00
|
|
|
parent::setUp();
|
|
|
|
$this->createUser('foo', 'foo');
|
|
|
|
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsMountedHomeStorage(): void {
|
2019-02-22 13:07:26 +01:00
|
|
|
$user = $this->createMock(IUser::class);
|
|
|
|
$user->method('getUID')
|
|
|
|
->willReturn('foo');
|
|
|
|
$user->method('getHome')
|
|
|
|
->willReturn('foo');
|
2023-10-23 13:22:23 +02:00
|
|
|
$storage = new Home(['user' => $user]);
|
2019-02-22 13:07:26 +01:00
|
|
|
|
2016-11-16 11:07:26 +01:00
|
|
|
$fileInfo = new FileInfo(
|
|
|
|
'',
|
2023-10-23 13:22:23 +02:00
|
|
|
$storage,
|
|
|
|
'',
|
|
|
|
[],
|
|
|
|
new HomeMountPoint($user, $storage, '/foo/files')
|
|
|
|
);
|
2016-11-16 11:07:26 +01:00
|
|
|
$this->assertFalse($fileInfo->isMounted());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsMountedNonHomeStorage(): void {
|
2023-10-23 13:22:23 +02:00
|
|
|
$storage = new Temporary();
|
2016-11-16 11:07:26 +01:00
|
|
|
$fileInfo = new FileInfo(
|
|
|
|
'',
|
2023-10-23 13:22:23 +02:00
|
|
|
$storage,
|
|
|
|
'',
|
|
|
|
[],
|
|
|
|
new MountPoint($storage, '/foo/files/bar')
|
|
|
|
);
|
2016-11-16 11:07:26 +01:00
|
|
|
$this->assertTrue($fileInfo->isMounted());
|
|
|
|
}
|
|
|
|
}
|