]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix mount config unit tests
authorVincent Petry <pvince81@owncloud.com>
Fri, 13 Mar 2015 16:43:38 +0000 (17:43 +0100)
committerVincent Petry <pvince81@owncloud.com>
Fri, 13 Mar 2015 16:43:38 +0000 (17:43 +0100)
Fix expected result now that it returns the status.
Added isset for some properties that are not always present.

apps/files_external/lib/config.php
apps/files_external/tests/mountconfig.php

index 378bedfa8debb99d72da8af5e23743a7b04a3713..23750dbb3fab268ee4ffeb645a7a4bd38389e5a9 100644 (file)
@@ -347,8 +347,6 @@ class OC_Mount_Config {
                                        $mountPoint = substr($mountPoint, 13);
 
                                        $config = array(
-                                               'id' => (int) $mount['id'],
-                                               'storage_id' => (int) $mount['storage_id'],
                                                'class' => $mount['class'],
                                                'mountpoint' => $mountPoint,
                                                'backend' => $backends[$mount['class']]['backend'],
@@ -357,6 +355,12 @@ class OC_Mount_Config {
                                                'applicable' => array('groups' => array($group), 'users' => array()),
                                                'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
                                        );
+                                       if (isset($mount['id'])) {
+                                               $config['id'] = (int)$mount['id'];
+                                       }
+                                       if (isset($mount['storage_id'])) {
+                                               $config['storage_id'] = (int)$mount['storage_id'];
+                                       }
                                        if (isset($mount['mountOptions'])) {
                                                $config['mountOptions'] = $mount['mountOptions'];
                                        }
@@ -386,8 +390,6 @@ class OC_Mount_Config {
                                        // Remove '/$user/files/' from mount point
                                        $mountPoint = substr($mountPoint, 13);
                                        $config = array(
-                                               'id' => (int) $mount['id'],
-                                               'storage_id' => (int) $mount['storage_id'],
                                                'class' => $mount['class'],
                                                'mountpoint' => $mountPoint,
                                                'backend' => $backends[$mount['class']]['backend'],
@@ -396,6 +398,12 @@ class OC_Mount_Config {
                                                'applicable' => array('groups' => array(), 'users' => array($user)),
                                                'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
                                        );
+                                       if (isset($mount['id'])) {
+                                               $config['id'] = (int)$mount['id'];
+                                       }
+                                       if (isset($mount['storage_id'])) {
+                                               $config['storage_id'] = (int)$mount['storage_id'];
+                                       }
                                        if (isset($mount['mountOptions'])) {
                                                $config['mountOptions'] = $mount['mountOptions'];
                                        }
@@ -433,8 +441,6 @@ class OC_Mount_Config {
                                }
                                $mount['options'] = self::decryptPasswords($mount['options']);
                                $config = array(
-                                       'id' => (int) $mount['id'],
-                                       'storage_id' => (int) $mount['storage_id'],
                                        'class' => $mount['class'],
                                        // Remove '/uid/files/' from mount point
                                        'mountpoint' => substr($mountPoint, strlen($uid) + 8),
@@ -442,6 +448,12 @@ class OC_Mount_Config {
                                        'options' => $mount['options'],
                                        'status' => self::getBackendStatus($mount['class'], $mount['options'], true)
                                );
+                               if (isset($mount['id'])) {
+                                       $config['id'] = (int)$mount['id'];
+                               }
+                               if (isset($mount['storage_id'])) {
+                                       $config['storage_id'] = (int)$mount['storage_id'];
+                               }
                                if (isset($mount['mountOptions'])) {
                                        $config['mountOptions'] = $mount['mountOptions'];
                                }
index f00812c5671c1656399266c9e124bc65e384703e..645f0c64e11b3020de6858e9cd4b5a6faeed70e6 100644 (file)
@@ -252,7 +252,7 @@ class Test_Mount_Config extends \Test\TestCase {
                        'password' => '12345',
                );
 
-               $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Dummy_Storage', $storageOptions, $mountType, $applicable, $isPersonal));
+               $this->assertEquals(0, OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Dummy_Storage', $storageOptions, $mountType, $applicable, $isPersonal));
 
                $config = $this->readGlobalConfig();
                $this->assertEquals(1, count($config));
@@ -279,7 +279,7 @@ class Test_Mount_Config extends \Test\TestCase {
                        'password' => '12345',
                );
 
-               $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Dummy_Storage', $storageOptions, $mountType, $applicable, $isPersonal));
+               $this->assertEquals(0, OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Dummy_Storage', $storageOptions, $mountType, $applicable, $isPersonal));
 
                $config = $this->readUserConfig();
                $this->assertEquals(1, count($config));
@@ -382,7 +382,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -422,7 +423,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -459,7 +461,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                $mountPoint,
                                'Test_Mount_Config_Dummy_Storage',
@@ -492,7 +495,8 @@ class Test_Mount_Config extends \Test\TestCase {
 
                // edit
                $mountConfig['host'] = 'anothersmbhost';
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                $mountPoint,
                                'Test_Mount_Config_Dummy_Storage',
@@ -557,7 +561,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -598,7 +603,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -707,7 +713,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // add mount point as "test" user
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -750,7 +757,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -761,7 +769,8 @@ class Test_Mount_Config extends \Test\TestCase {
                        )
                );
 
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -772,7 +781,8 @@ class Test_Mount_Config extends \Test\TestCase {
                        )
                );
 
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -783,7 +793,8 @@ class Test_Mount_Config extends \Test\TestCase {
                        )
                );
 
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -821,7 +832,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // write config
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -839,7 +851,8 @@ class Test_Mount_Config extends \Test\TestCase {
                        'share' => 'anothersmbshare',
                        'root' => 'anothersmbroot'
                );
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -952,7 +965,8 @@ class Test_Mount_Config extends \Test\TestCase {
 
                // Add mount points
                foreach($mounts as $i => $mount) {
-                       $this->assertTrue(
+                       $this->assertEquals(
+                               0,
                                OC_Mount_Config::addMountPoint(
                                        '/ext',
                                        'Test_Mount_Config_Dummy_Storage',
@@ -987,7 +1001,8 @@ class Test_Mount_Config extends \Test\TestCase {
                        'share' => '',
                );
 
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                $class,
@@ -1005,7 +1020,8 @@ class Test_Mount_Config extends \Test\TestCase {
                        $mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
 
                // Simulate changed mount options (without priority set)
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                $class,
@@ -1035,7 +1051,8 @@ class Test_Mount_Config extends \Test\TestCase {
                );
 
                // Create personal mount point
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                'Test_Mount_Config_Dummy_Storage',
@@ -1066,7 +1083,8 @@ class Test_Mount_Config extends \Test\TestCase {
                $applicable = 'all';
                $isPersonal = false;
 
-               $this->assertTrue(
+               $this->assertEquals(
+                       0,
                        OC_Mount_Config::addMountPoint(
                                '/ext',
                                $storageClass,