MountTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\Files\Mount;
  8. use OC\Files\Storage\StorageFactory;
  9. use OC\Files\Storage\Wrapper\Wrapper;
  10. class MountTest extends \Test\TestCase {
  11. public function testFromStorageObject(): void {
  12. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  13. ->disableOriginalConstructor()
  14. ->getMock();
  15. $mount = new \OC\Files\Mount\MountPoint($storage, '/foo');
  16. $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
  17. }
  18. public function testFromStorageClassname(): void {
  19. $mount = new \OC\Files\Mount\MountPoint('\OC\Files\Storage\Temporary', '/foo');
  20. $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
  21. }
  22. public function testWrapper(): void {
  23. $test = $this;
  24. $wrapper = function ($mountPoint, $storage) use (&$test) {
  25. $test->assertEquals('/foo/', $mountPoint);
  26. $test->assertInstanceOf('\OC\Files\Storage\Storage', $storage);
  27. return new Wrapper(['storage' => $storage]);
  28. };
  29. $loader = new StorageFactory();
  30. $loader->addStorageWrapper('test_wrapper', $wrapper);
  31. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  32. ->disableOriginalConstructor()
  33. ->getMock();
  34. $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', [], $loader);
  35. $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
  36. }
  37. }