diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-03-18 22:37:02 +0400 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-03-19 13:52:22 +0400 |
commit | e0dada704cebb0a61f6fd8e845f0d8865a373672 (patch) | |
tree | a2c1e954a68634004a750d3b096a00812a24a7ff /apps | |
parent | ff5b79edebf6c1d1f492a52882c3b2a4f7a77f42 (diff) |
Added ext storage unit tests for writing then reload the mount config
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/tests/mountconfig.php | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php index a22c7424c69..090b5f8e5cf 100644 --- a/apps/files_external/tests/mountconfig.php +++ b/apps/files_external/tests/mountconfig.php @@ -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); + } } |