2013-06-07 15:40:38 +00: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 14:54:42 +00:00
|
|
|
use OC\Files\Storage\StorageFactory;
|
2013-06-28 16:18:12 +00:00
|
|
|
use OC\Files\Storage\Wrapper\Wrapper;
|
2013-06-07 15:40:38 +00:00
|
|
|
|
2016-05-20 13:38:20 +00:00
|
|
|
class MountTest extends \Test\TestCase {
|
2013-06-07 15:40:38 +00:00
|
|
|
public function testFromStorageObject() {
|
|
|
|
$storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2014-11-24 14:54:42 +00:00
|
|
|
$mount = new \OC\Files\Mount\MountPoint($storage, '/foo');
|
2013-06-07 15:40:38 +00:00
|
|
|
$this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFromStorageClassname() {
|
2014-11-24 14:54:42 +00:00
|
|
|
$mount = new \OC\Files\Mount\MountPoint('\OC\Files\Storage\Temporary', '/foo');
|
2013-06-07 15:40:38 +00: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 14:54:42 +00:00
|
|
|
$loader = new StorageFactory();
|
2014-06-02 13:12:31 +00:00
|
|
|
$loader->addStorageWrapper('test_wrapper', $wrapper);
|
2013-06-07 15:40:38 +00:00
|
|
|
|
|
|
|
$storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2014-11-24 14:54:42 +00:00
|
|
|
$mount = new \OC\Files\Mount\MountPoint($storage, '/foo', array(), $loader);
|
2013-06-28 16:18:12 +00:00
|
|
|
$this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage());
|
2013-06-07 15:40:38 +00:00
|
|
|
}
|
|
|
|
}
|