mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
Some changes to tests, maybe they pass
Mostly about getting a session for Sharing, even though we're on the command line
This commit is contained in:
parent
3ea645f8e5
commit
f44a26432c
@ -253,7 +253,7 @@ class PreferencesCommandTest extends CommandBase
|
||||
$set = array($this->config_name => null);
|
||||
$old = array($this->config_name => 'It will log whatever');
|
||||
|
||||
$prefs = new Api\Preferences(in_array($type, 'default', 'forced') ? $type : $account);
|
||||
$prefs = new Api\Preferences(in_array($type, array('default', 'forced')) ? $type : $account);
|
||||
$prefs->add(static::APP, $this->config_name, $old[$this->config_name], in_array($type, array('default', 'forced')) ? $type : 'user');
|
||||
$prefs->save_repository(false, $type);
|
||||
|
||||
|
@ -240,16 +240,8 @@ class Sharing
|
||||
// --> create a new anon session
|
||||
if ($keep_session === false && $GLOBALS['egw']->sharing->need_session() || is_null($keep_session))
|
||||
{
|
||||
// create session without checking auth: create(..., false, false)
|
||||
if (!($sessionid = $GLOBALS['egw']->session->create('anonymous@'.$GLOBALS['egw_info']['user']['domain'],
|
||||
'', 'text', false, false)))
|
||||
{
|
||||
sleep(1);
|
||||
return static::share_fail(
|
||||
'500 Internal Server Error',
|
||||
"Failed to create session: ".$GLOBALS['egw']->session->reason."\n"
|
||||
);
|
||||
}
|
||||
$sessionid = static::create_new_session();
|
||||
|
||||
$GLOBALS['egw']->sharing->after_login();
|
||||
}
|
||||
// we have a session we want to keep, but share owner is different from current user and we dont need filemanager UI
|
||||
@ -274,6 +266,21 @@ class Sharing
|
||||
return $sessionid;
|
||||
}
|
||||
|
||||
public static function create_new_session()
|
||||
{
|
||||
// create session without checking auth: create(..., false, false)
|
||||
if (!($sessionid = $GLOBALS['egw']->session->create('anonymous@'.$GLOBALS['egw_info']['user']['domain'],
|
||||
'', 'text', false, false)))
|
||||
{
|
||||
sleep(1);
|
||||
return static::share_fail(
|
||||
'500 Internal Server Error',
|
||||
"Failed to create session: ".$GLOBALS['egw']->session->reason."\n"
|
||||
);
|
||||
}
|
||||
return $sessionid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to instanciate a share
|
||||
*
|
||||
|
@ -346,7 +346,7 @@ class SharingBase extends LoggedInTest
|
||||
$files[] = $file = $path.'test_file.txt';
|
||||
$this->assertTrue(
|
||||
file_put_contents(Vfs::PREFIX.$file, $content) !== FALSE,
|
||||
'Unable to write test file - check file permissions for CLI user'
|
||||
'Unable to write test file "' . Vfs::PREFIX . $file .'" - check file permissions for CLI user'
|
||||
);
|
||||
|
||||
// Subdirectory
|
||||
@ -364,7 +364,7 @@ class SharingBase extends LoggedInTest
|
||||
$files[] = $file = $dir.'subdir_test_file.txt';
|
||||
$this->assertTrue(
|
||||
file_put_contents(Vfs::PREFIX.$file, $content) !== FALSE,
|
||||
'Unable to write test file - check file permissions for CLI user'
|
||||
'Unable to write test file "' . Vfs::PREFIX . $file .'" - check file permissions for CLI user'
|
||||
);
|
||||
|
||||
// Symlinked file
|
||||
@ -547,7 +547,7 @@ class SharingBase extends LoggedInTest
|
||||
'noheader' => true,
|
||||
'nonavbar' => 'always', // true would cause eTemplate to reset it to false for non-popups!
|
||||
'currentapp' => 'filemanager',
|
||||
'autocreate_session_callback' => 'EGroupware\\Api\\Vfs\\Sharing::create_session',
|
||||
'autocreate_session_callback' => 'EGroupware\\Api\\Vfs\\TestSharing::create_session',
|
||||
'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm)
|
||||
)
|
||||
);
|
||||
@ -564,3 +564,22 @@ class SharingBase extends LoggedInTest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this class for sharing so we can make sure we get a session ID, even
|
||||
* though we're on the command line
|
||||
*/
|
||||
class TestSharing extends Api\Sharing {
|
||||
|
||||
public static function create_new_session()
|
||||
{
|
||||
if (!($sessionid = $GLOBALS['egw']->session->create('anonymous@'.$GLOBALS['egw_info']['user']['domain'],
|
||||
'', 'text', false, false)))
|
||||
{
|
||||
// Allow for testing
|
||||
$sessionid = 'CLI_TEST';
|
||||
$GLOBALS['egw']->session->session_id = $sessionid;
|
||||
}
|
||||
return $sessionid;
|
||||
}
|
||||
}
|
@ -42,9 +42,9 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
protected $warnings = array();
|
||||
|
||||
/**
|
||||
* Set up tracker
|
||||
* Set up import
|
||||
*/
|
||||
protected function init(importexport_definition &$definition)
|
||||
protected function init(importexport_definition &$definition, importexport_import_csv &$import_csv=NULL)
|
||||
{
|
||||
// fetch the addressbook bo
|
||||
$this->bo= new calendar_boupdate();
|
||||
@ -224,7 +224,7 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
$this->resource_so = new resources_so();
|
||||
}
|
||||
$result = $this->resource_so->search($search,'res_id');
|
||||
if(count($result) >= 1) {
|
||||
if($result && count($result) >= 1) {
|
||||
$id = $resource['type'].$result[0]['res_id'];
|
||||
break;
|
||||
}
|
||||
|
@ -45,6 +45,21 @@ class SetProjectManagerTest extends \EGroupware\Api\AppTest
|
||||
|
||||
$this->mockTracking($this->bo, 'infolog_tracking');
|
||||
|
||||
// Make sure projects are not there first
|
||||
$pm_numbers = array(
|
||||
'TEST',
|
||||
'SUB-TEST'
|
||||
);
|
||||
foreach($pm_numbers as $number)
|
||||
{
|
||||
$project = $this->pm_bo->read(Array('pm_number' => $number));
|
||||
if($project && $project['pm_id'])
|
||||
{
|
||||
$this->pm_bo->delete($project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->makeProject();
|
||||
}
|
||||
|
||||
@ -691,7 +706,7 @@ class SetProjectManagerTest extends \EGroupware\Api\AppTest
|
||||
$element_bo = new \projectmanager_elements_bo();
|
||||
$element_count = 0;
|
||||
|
||||
foreach($element_bo->search(array('pm_id' => $this->pm_id), false) as $element)
|
||||
foreach((array)$element_bo->search(array('pm_id' => $this->pm_id), false) as $element)
|
||||
{
|
||||
$element_count++;
|
||||
$this->assertEquals($this->info_id, $element['pe_app_id']);
|
||||
|
Loading…
Reference in New Issue
Block a user