mount.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\Loader;
  10. use OC\Files\Storage\Wrapper\Wrapper;
  11. class Mount extends \PHPUnit_Framework_TestCase {
  12. public function testFromStorageObject() {
  13. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  14. ->disableOriginalConstructor()
  15. ->getMock();
  16. $mount = new \OC\Files\Mount\Mount($storage, '/foo');
  17. $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
  18. }
  19. public function testFromStorageClassname() {
  20. $mount = new \OC\Files\Mount\Mount('\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 Loader();
  31. $loader->addStorageWrapper($wrapper);
  32. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  33. ->disableOriginalConstructor()
  34. ->getMock();
  35. $mount = new \OC\Files\Mount\Mount($storage, '/foo', array(), $loader);
  36. $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
  37. }
  38. }