1
0

FileInfoTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Test\Files;
  7. use OC\Files\FileInfo;
  8. use OC\Files\Mount\HomeMountPoint;
  9. use OC\Files\Mount\MountPoint;
  10. use OC\Files\Storage\Home;
  11. use OC\Files\Storage\Temporary;
  12. use OCP\IConfig;
  13. use OCP\IUser;
  14. use Test\TestCase;
  15. use Test\Traits\UserTrait;
  16. class FileInfoTest extends TestCase {
  17. use UserTrait;
  18. private $config;
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->createUser('foo', 'foo');
  22. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  23. }
  24. public function testIsMountedHomeStorage() {
  25. $user = $this->createMock(IUser::class);
  26. $user->method('getUID')
  27. ->willReturn('foo');
  28. $user->method('getHome')
  29. ->willReturn('foo');
  30. $storage = new Home(['user' => $user]);
  31. $fileInfo = new FileInfo(
  32. '',
  33. $storage,
  34. '',
  35. [],
  36. new HomeMountPoint($user, $storage, '/foo/files')
  37. );
  38. $this->assertFalse($fileInfo->isMounted());
  39. }
  40. public function testIsMountedNonHomeStorage() {
  41. $storage = new Temporary();
  42. $fileInfo = new FileInfo(
  43. '',
  44. $storage,
  45. '',
  46. [],
  47. new MountPoint($storage, '/foo/files/bar')
  48. );
  49. $this->assertTrue($fileInfo->isMounted());
  50. }
  51. }