1
0

MountTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  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\Mount;
  9. use OC\Files\Storage\StorageFactory;
  10. use OC\Files\Storage\Wrapper\Wrapper;
  11. class MountTest extends \Test\TestCase {
  12. public function testFromStorageObject() {
  13. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  14. ->disableOriginalConstructor()
  15. ->getMock();
  16. $mount = new \OC\Files\Mount\MountPoint($storage, '/foo');
  17. $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
  18. }
  19. public function testFromStorageClassname() {
  20. $mount = new \OC\Files\Mount\MountPoint('\OC\Files\Storage\Temporary', '/foo');
  21. $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
  22. }
  23. public function testWrapper() {
  24. $test = $this;
  25. $wrapper = function ($mountPoint, $storage) use (&$test) {
  26. $test->assertEquals('/foo/', $mountPoint);
  27. $test->assertInstanceOf('\OC\Files\Storage\Storage', $storage);
  28. return new Wrapper(array('storage' => $storage));
  29. };
  30. $loader = new StorageFactory();
  31. $loader->addStorageWrapper('test_wrapper', $wrapper);
  32. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  33. ->disableOriginalConstructor()
  34. ->getMock();
  35. $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', array(), $loader);
  36. $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
  37. }
  38. }