2013-06-07 19:40:38 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\Files\Mount;
|
|
|
|
|
|
|
|
|
2014-11-24 17:54:42 +03:00
|
|
|
use OC\Files\Storage\StorageFactory;
|
2013-06-28 20:18:12 +04:00
|
|
|
use OC\Files\Storage\Wrapper\Wrapper;
|
2013-06-07 19:40:38 +04:00
|
|
|
|
2016-05-20 16:38:20 +03:00
|
|
|
class MountTest extends \Test\TestCase {
|
2013-06-07 19:40:38 +04:00
|
|
|
public function testFromStorageObject() {
|
|
|
|
$storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2014-11-24 17:54:42 +03:00
|
|
|
$mount = new \OC\Files\Mount\MountPoint($storage, '/foo');
|
2013-06-07 19:40:38 +04:00
|
|
|
$this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFromStorageClassname() {
|
2014-11-24 17:54:42 +03:00
|
|
|
$mount = new \OC\Files\Mount\MountPoint('\OC\Files\Storage\Temporary', '/foo');
|
2013-06-07 19:40:38 +04:00
|
|
|
$this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWrapper() {
|
|
|
|
$test = $this;
|
|
|
|
$wrapper = function ($mountPoint, $storage) use (&$test) {
|
|
|
|
$test->assertEquals('/foo/', $mountPoint);
|
|
|
|
$test->assertInstanceOf('\OC\Files\Storage\Storage', $storage);
|
|
|
|
return new Wrapper(array('storage' => $storage));
|
|
|
|
};
|
|
|
|
|
2014-11-24 17:54:42 +03:00
|
|
|
$loader = new StorageFactory();
|
2014-06-02 17:12:31 +04:00
|
|
|
$loader->addStorageWrapper('test_wrapper', $wrapper);
|
2013-06-07 19:40:38 +04:00
|
|
|
|
|
|
|
$storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2014-11-24 17:54:42 +03:00
|
|
|
$mount = new \OC\Files\Mount\MountPoint($storage, '/foo', array(), $loader);
|
2013-06-28 20:18:12 +04:00
|
|
|
$this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
|
2013-06-07 19:40:38 +04:00
|
|
|
}
|
|
|
|
}
|