Fix mount config unit test failures

Because setStorageId now instantiates storages, they might throw
exceptions if arguments are missing.

This fixes the unit test to not throw exceptions and have their default
config arguments set.
remotes/origin/create-share-target-reuse
Vincent Petry 12 years ago
parent 956de27e94
commit c4b02176dc
  1. 36
      apps/files_external/tests/mountconfig.php

@ -184,7 +184,13 @@ class Test_Mount_Config extends \Test\TestCase {
$applicable = 'all'; $applicable = 'all';
$isPersonal = false; $isPersonal = false;
$this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', array(), $mountType, $applicable, $isPersonal)); $storageOptions = array(
'host' => 'localhost',
'user' => 'testuser',
'password' => '12345',
);
$this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', $storageOptions, $mountType, $applicable, $isPersonal));
$config = $this->readGlobalConfig(); $config = $this->readGlobalConfig();
$this->assertEquals(1, count($config)); $this->assertEquals(1, count($config));
@ -205,7 +211,13 @@ class Test_Mount_Config extends \Test\TestCase {
$applicable = self::TEST_USER1; $applicable = self::TEST_USER1;
$isPersonal = true; $isPersonal = true;
$this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', array(), $mountType, $applicable, $isPersonal)); $storageOptions = array(
'host' => 'localhost',
'user' => 'testuser',
'password' => '12345',
);
$this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', $storageOptions, $mountType, $applicable, $isPersonal));
$config = $this->readUserConfig(); $config = $this->readUserConfig();
$this->assertEquals(1, count($config)); $this->assertEquals(1, count($config));
@ -236,8 +248,14 @@ class Test_Mount_Config extends \Test\TestCase {
implode(',', array_keys($this->allBackends)) implode(',', array_keys($this->allBackends))
); );
$storageOptions = array(
'host' => 'localhost',
'user' => 'testuser',
'password' => '12345',
);
// non-local but forbidden // non-local but forbidden
$this->assertFalse(OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', array(), $mountType, $applicable, $isPersonal)); $this->assertFalse(OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', $storageOptions, $mountType, $applicable, $isPersonal));
$this->assertFalse(file_exists($this->userHome . '/mount.json')); $this->assertFalse(file_exists($this->userHome . '/mount.json'));
} }
@ -629,7 +647,8 @@ class Test_Mount_Config extends \Test\TestCase {
'host' => 'someost', 'host' => 'someost',
'user' => 'someuser', 'user' => 'someuser',
'password' => 'somepassword', 'password' => 'somepassword',
'root' => 'someroot' 'root' => 'someroot',
'share' => '',
); );
// add mount point as "test" user // add mount point as "test" user
@ -872,7 +891,8 @@ class Test_Mount_Config extends \Test\TestCase {
'host' => 'somehost', 'host' => 'somehost',
'user' => 'someuser', 'user' => 'someuser',
'password' => 'somepassword', 'password' => 'somepassword',
'root' => 'someroot' 'root' => 'someroot',
'share' => '',
); );
// Add mount points // Add mount points
@ -908,7 +928,8 @@ class Test_Mount_Config extends \Test\TestCase {
'host' => 'somehost', 'host' => 'somehost',
'user' => 'someuser', 'user' => 'someuser',
'password' => 'somepassword', 'password' => 'somepassword',
'root' => 'someroot' 'root' => 'someroot',
'share' => '',
); );
$this->assertTrue( $this->assertTrue(
@ -954,7 +975,8 @@ class Test_Mount_Config extends \Test\TestCase {
'host' => 'somehost', 'host' => 'somehost',
'user' => 'someuser', 'user' => 'someuser',
'password' => 'somepassword', 'password' => 'somepassword',
'root' => 'someroot' 'root' => 'someroot',
'share' => '',
); );
// Create personal mount point // Create personal mount point

Loading…
Cancel
Save