123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace Test\Files\Mount;
- use OC\Files\Storage\StorageFactory;
- use OCP\Files\Storage;
- class DummyStorage {
- }
- class MountPointTest extends \Test\TestCase {
- public function testGetStorage() {
- $storage = $this->createMock(Storage::class);
- $storage->expects($this->once())
- ->method('getId')
- ->willReturn(123);
- $loader = $this->createMock(StorageFactory::class);
- $loader->expects($this->once())
- ->method('wrap')
- ->willReturn($storage);
- $mountPoint = new \OC\Files\Mount\MountPoint(
-
- '\Test\Files\Mount\DummyStorage',
- '/mountpoint',
- null,
- $loader
- );
- $this->assertEquals($storage, $mountPoint->getStorage());
- $this->assertEquals(123, $mountPoint->getStorageId());
- $this->assertEquals('/mountpoint/', $mountPoint->getMountPoint());
- $mountPoint->setMountPoint('another');
- $this->assertEquals('/another/', $mountPoint->getMountPoint());
- }
- public function testInvalidStorage() {
- $loader = $this->createMock(StorageFactory::class);
- $loader->expects($this->once())
- ->method('wrap')
- ->will($this->throwException(new \Exception('Test storage init exception')));
- $called = false;
- $wrapper = function ($mountPoint, $storage) use ($called) {
- $called = true;
- };
- $mountPoint = new \OC\Files\Mount\MountPoint(
-
- '\Test\Files\Mount\DummyStorage',
- '/mountpoint',
- null,
- $loader
- );
- $this->assertNull($mountPoint->getStorage());
-
- $this->assertNull($mountPoint->getStorage());
- $this->assertNull($mountPoint->getStorageId());
-
- $mountPoint->wrapStorage($wrapper);
- $this->assertNull($mountPoint->getStorage());
-
- $this->assertFalse($called);
- }
- }
|