Shuffle around some code for better extendability

This commit is contained in:
nathangray 2018-04-09 09:58:44 -06:00
parent e675ab57d4
commit cbdbae2f9a

View File

@ -124,6 +124,10 @@ class SharingBase extends LoggedInTest
{ {
echo "\n".__METHOD__ . "($dir, $mode)\n"; echo "\n".__METHOD__ . "($dir, $mode)\n";
} }
if(substr($dir, -1) != '/')
{
$dir .= '/';
}
$this->files += $this->addFiles($dir); $this->files += $this->addFiles($dir);
$logged_in_files = array_map( $logged_in_files = array_map(
@ -139,12 +143,7 @@ class SharingBase extends LoggedInTest
// Create and use link // Create and use link
$extra = array(); $extra = array();
switch($mode) $this->getShareExtra($dir, $mode, $extra);
{
case Sharing::WRITABLE:
$extra['share_writable'] = TRUE;
break;
}
$this->shareLink($dir, $mode, $extra); $this->shareLink($dir, $mode, $extra);
$files = Vfs::find('/', static::VFS_OPTIONS); $files = Vfs::find('/', static::VFS_OPTIONS);
@ -164,6 +163,24 @@ class SharingBase extends LoggedInTest
} }
} }
/**
* Get the extra information required to create a share link for the given
* directory, with the given mode
*
* @param string $dir Share target
* @param int $mode Share mode
* @param Array $extra
*/
protected function getShareExtra($dir, $mode, &$extra)
{
switch($mode)
{
case Sharing::WRITABLE:
$extra['share_writable'] = TRUE;
break;
}
}
/** /**
* Check the access permissions for one file/directory * Check the access permissions for one file/directory
* *
@ -246,7 +263,12 @@ class SharingBase extends LoggedInTest
$backup = Vfs::$is_root; $backup = Vfs::$is_root;
Vfs::$is_root = true; Vfs::$is_root = true;
$url = Filesystem\StreamWrapper::SCHEME.'://default'. realpath(__DIR__ . '/../fixtures/Vfs/filesystem_mount'). $fs_path = realpath(__DIR__ . '/../fixtures/Vfs/filesystem_mount');
if(!file_exists($fs_path))
{
$this->fail("Missing filesystem test directory 'api/tests/fixtures/Vfs/filesystem_mount'");
}
$url = Filesystem\StreamWrapper::SCHEME.'://default'. $fs_path.
'?user='.$GLOBALS['egw_info']['user']['account_id'].'&group=Default&mode=775'; '?user='.$GLOBALS['egw_info']['user']['account_id'].'&group=Default&mode=775';
$this->assertTrue(Vfs::mount($url,$path), "Unable to mount $url to $path"); $this->assertTrue(Vfs::mount($url,$path), "Unable to mount $url to $path");
Vfs::$is_root = $backup; Vfs::$is_root = $backup;