server/tests/lib/Files/Mount/MountTest.php

47 lines
1.5 KiB
PHP
Raw Normal View History

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;
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
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();
$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() {
$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));
};
$loader = new StorageFactory();
$loader->addStorageWrapper('test_wrapper', $wrapper);
2013-06-07 15:40:38 +00:00
$storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
->disableOriginalConstructor()
->getMock();
$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
}
}