]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added ext storage unit tests for writing then reload the mount config
authorVincent Petry <pvince81@owncloud.com>
Tue, 18 Mar 2014 18:37:02 +0000 (19:37 +0100)
committerVincent Petry <pvince81@owncloud.com>
Wed, 19 Mar 2014 09:52:22 +0000 (10:52 +0100)
apps/files_external/tests/mountconfig.php

index a22c7424c69135825fc1d15313a05a6d99553dbb..090b5f8e5cf748aa4ed17fab2e0399419e4ec79b 100644 (file)
@@ -113,7 +113,7 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
         * Test adding a global mount point
         */
        public function testAddGlobalMountPoint() {
-               $mountType = OC_Mount_Config::MOUNT_TYPE_GLOBAL;
+               $mountType = OC_Mount_Config::MOUNT_TYPE_USER;
                $applicable = 'all';
                $isPersonal = false;
 
@@ -186,4 +186,76 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
                $this->assertFalse(OC_Mount_Config::addMountPoint('/ext', $storageClass, array(), $mountType, $applicable, $isPersonal));
 
        }
+
+       /**
+        * Test reading and writing global config
+        */
+       public function testReadWriteGlobalConfig() {
+               $mountType = OC_Mount_Config::MOUNT_TYPE_USER;
+               $applicable = 'all';
+               $isPersonal = false;
+               $mountConfig = array(
+                       'host' => 'smbhost',
+                       'user' => 'smbuser',
+                       'password' => 'smbpassword',
+                       'share' => 'smbshare',
+                       'root' => 'smbroot'
+               );
+
+               // write config
+               $this->assertTrue(
+                       OC_Mount_Config::addMountPoint(
+                               '/ext',
+                               '\OC\Files\Storage\SMB',
+                               $mountConfig,
+                               $mountType,
+                               $applicable,
+                               $isPersonal
+                       )
+               );
+
+               // re-read config
+               $config = OC_Mount_Config::getSystemMountPoints();
+               $this->assertEquals(1, count($config));
+               $this->assertTrue(isset($config['ext']));
+               $this->assertEquals('\OC\Files\Storage\SMB', $config['ext']['class']);
+               $savedMountConfig = $config['ext']['configuration'];
+               $this->assertEquals($mountConfig, $savedMountConfig);
+       }
+
+       /**
+        * Test reading and writing config
+        */
+       public function testReadWritePersonalConfig() {
+               $mountType = OC_Mount_Config::MOUNT_TYPE_USER;
+               $applicable = 'test';
+               $isPersonal = true;
+               $mountConfig = array(
+                       'host' => 'smbhost',
+                       'user' => 'smbuser',
+                       'password' => 'smbpassword',
+                       'share' => 'smbshare',
+                       'root' => 'smbroot'
+               );
+
+               // write config
+               $this->assertTrue(
+                       OC_Mount_Config::addMountPoint(
+                               '/ext',
+                               '\OC\Files\Storage\SMB',
+                               $mountConfig,
+                               $mountType,
+                               $applicable,
+                               $isPersonal
+                       )
+               );
+
+               // re-read config
+               $config = OC_Mount_Config::getPersonalMountPoints();
+               $this->assertEquals(1, count($config));
+               $this->assertTrue(isset($config['ext']));
+               $this->assertEquals('\OC\Files\Storage\SMB', $config['ext']['class']);
+               $savedMountConfig = $config['ext']['configuration'];
+               $this->assertEquals($mountConfig, $savedMountConfig);
+       }
 }