Fix mount config unit tests
Fix expected result now that it returns the status. Added isset for some properties that are not always present.
This commit is contained in:
parent
34c8b1ac77
commit
fb4cf53253
|
@ -347,8 +347,6 @@ class OC_Mount_Config {
|
||||||
$mountPoint = substr($mountPoint, 13);
|
$mountPoint = substr($mountPoint, 13);
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
'id' => (int) $mount['id'],
|
|
||||||
'storage_id' => (int) $mount['storage_id'],
|
|
||||||
'class' => $mount['class'],
|
'class' => $mount['class'],
|
||||||
'mountpoint' => $mountPoint,
|
'mountpoint' => $mountPoint,
|
||||||
'backend' => $backends[$mount['class']]['backend'],
|
'backend' => $backends[$mount['class']]['backend'],
|
||||||
|
@ -357,6 +355,12 @@ class OC_Mount_Config {
|
||||||
'applicable' => array('groups' => array($group), 'users' => array()),
|
'applicable' => array('groups' => array($group), 'users' => array()),
|
||||||
'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
|
'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'])) {
|
if (isset($mount['mountOptions'])) {
|
||||||
$config['mountOptions'] = $mount['mountOptions'];
|
$config['mountOptions'] = $mount['mountOptions'];
|
||||||
}
|
}
|
||||||
|
@ -386,8 +390,6 @@ class OC_Mount_Config {
|
||||||
// Remove '/$user/files/' from mount point
|
// Remove '/$user/files/' from mount point
|
||||||
$mountPoint = substr($mountPoint, 13);
|
$mountPoint = substr($mountPoint, 13);
|
||||||
$config = array(
|
$config = array(
|
||||||
'id' => (int) $mount['id'],
|
|
||||||
'storage_id' => (int) $mount['storage_id'],
|
|
||||||
'class' => $mount['class'],
|
'class' => $mount['class'],
|
||||||
'mountpoint' => $mountPoint,
|
'mountpoint' => $mountPoint,
|
||||||
'backend' => $backends[$mount['class']]['backend'],
|
'backend' => $backends[$mount['class']]['backend'],
|
||||||
|
@ -396,6 +398,12 @@ class OC_Mount_Config {
|
||||||
'applicable' => array('groups' => array(), 'users' => array($user)),
|
'applicable' => array('groups' => array(), 'users' => array($user)),
|
||||||
'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
|
'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'])) {
|
if (isset($mount['mountOptions'])) {
|
||||||
$config['mountOptions'] = $mount['mountOptions'];
|
$config['mountOptions'] = $mount['mountOptions'];
|
||||||
}
|
}
|
||||||
|
@ -433,8 +441,6 @@ class OC_Mount_Config {
|
||||||
}
|
}
|
||||||
$mount['options'] = self::decryptPasswords($mount['options']);
|
$mount['options'] = self::decryptPasswords($mount['options']);
|
||||||
$config = array(
|
$config = array(
|
||||||
'id' => (int) $mount['id'],
|
|
||||||
'storage_id' => (int) $mount['storage_id'],
|
|
||||||
'class' => $mount['class'],
|
'class' => $mount['class'],
|
||||||
// Remove '/uid/files/' from mount point
|
// Remove '/uid/files/' from mount point
|
||||||
'mountpoint' => substr($mountPoint, strlen($uid) + 8),
|
'mountpoint' => substr($mountPoint, strlen($uid) + 8),
|
||||||
|
@ -442,6 +448,12 @@ class OC_Mount_Config {
|
||||||
'options' => $mount['options'],
|
'options' => $mount['options'],
|
||||||
'status' => self::getBackendStatus($mount['class'], $mount['options'], true)
|
'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'])) {
|
if (isset($mount['mountOptions'])) {
|
||||||
$config['mountOptions'] = $mount['mountOptions'];
|
$config['mountOptions'] = $mount['mountOptions'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,7 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
'password' => '12345',
|
'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();
|
$config = $this->readGlobalConfig();
|
||||||
$this->assertEquals(1, count($config));
|
$this->assertEquals(1, count($config));
|
||||||
|
@ -279,7 +279,7 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
'password' => '12345',
|
'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();
|
$config = $this->readUserConfig();
|
||||||
$this->assertEquals(1, count($config));
|
$this->assertEquals(1, count($config));
|
||||||
|
@ -382,7 +382,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -422,7 +423,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -459,7 +461,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
$mountPoint,
|
$mountPoint,
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -492,7 +495,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
$mountConfig['host'] = 'anothersmbhost';
|
$mountConfig['host'] = 'anothersmbhost';
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
$mountPoint,
|
$mountPoint,
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -557,7 +561,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -598,7 +603,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -707,7 +713,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// add mount point as "test" user
|
// add mount point as "test" user
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -750,7 +757,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'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(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'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(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'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(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -821,7 +832,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// write config
|
// write config
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -839,7 +851,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
'share' => 'anothersmbshare',
|
'share' => 'anothersmbshare',
|
||||||
'root' => 'anothersmbroot'
|
'root' => 'anothersmbroot'
|
||||||
);
|
);
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -952,7 +965,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
|
|
||||||
// Add mount points
|
// Add mount points
|
||||||
foreach($mounts as $i => $mount) {
|
foreach($mounts as $i => $mount) {
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -987,7 +1001,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
'share' => '',
|
'share' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
$class,
|
$class,
|
||||||
|
@ -1005,7 +1020,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
$mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
|
$mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
|
||||||
|
|
||||||
// Simulate changed mount options (without priority set)
|
// Simulate changed mount options (without priority set)
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
$class,
|
$class,
|
||||||
|
@ -1035,7 +1051,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create personal mount point
|
// Create personal mount point
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
'Test_Mount_Config_Dummy_Storage',
|
'Test_Mount_Config_Dummy_Storage',
|
||||||
|
@ -1066,7 +1083,8 @@ class Test_Mount_Config extends \Test\TestCase {
|
||||||
$applicable = 'all';
|
$applicable = 'all';
|
||||||
$isPersonal = false;
|
$isPersonal = false;
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertEquals(
|
||||||
|
0,
|
||||||
OC_Mount_Config::addMountPoint(
|
OC_Mount_Config::addMountPoint(
|
||||||
'/ext',
|
'/ext',
|
||||||
$storageClass,
|
$storageClass,
|
||||||
|
|
Loading…
Reference in New Issue