FileInfoTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\Files;
  9. use OC\Files\FileInfo;
  10. use OC\Files\Mount\HomeMountPoint;
  11. use OC\Files\Mount\MountPoint;
  12. use OC\Files\Storage\Home;
  13. use OC\Files\Storage\Temporary;
  14. use OCP\IConfig;
  15. use OCP\IUser;
  16. use Test\TestCase;
  17. use Test\Traits\UserTrait;
  18. class FileInfoTest extends TestCase {
  19. use UserTrait;
  20. private $config;
  21. protected function setUp(): void {
  22. parent::setUp();
  23. $this->createUser('foo', 'foo');
  24. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  25. }
  26. public function testIsMountedHomeStorage() {
  27. $user = $this->createMock(IUser::class);
  28. $user->method('getUID')
  29. ->willReturn('foo');
  30. $user->method('getHome')
  31. ->willReturn('foo');
  32. $storage = new Home(['user' => $user]);
  33. $fileInfo = new FileInfo(
  34. '',
  35. $storage,
  36. '',
  37. [],
  38. new HomeMountPoint($user, $storage, '/foo/files')
  39. );
  40. $this->assertFalse($fileInfo->isMounted());
  41. }
  42. public function testIsMountedNonHomeStorage() {
  43. $storage = new Temporary();
  44. $fileInfo = new FileInfo(
  45. '',
  46. $storage,
  47. '',
  48. [],
  49. new MountPoint($storage, '/foo/files/bar')
  50. );
  51. $this->assertTrue($fileInfo->isMounted());
  52. }
  53. }