示例#1
0
 /**
  * Executed once before each test method.
  */
 public function setUp()
 {
     if (self::$InitProcessToRestore === null) {
         self::$InitProcessToRestore = ProcManager::getInstance()->getCurrentProcess();
     }
     $this->fixture_file1_path = USERS_PATH . '/john/' . USERS_FILES_DIR . '/myHomeFile.ext';
     $this->fixture_metafile1_path = USERS_PATH . '/john/' . USERS_METAFILES_DIR . '/' . USERS_FILES_DIR . '/myHomeFile.ext.xml';
     $this->fixture_file2_path = EYEOS_TESTS_TMP_PATH . '/mySysFile.ext';
     $this->fixture_dir1_path = USERS_PATH . '/john/' . USERS_FILES_DIR . '/myHomeDir';
     $this->fixture_dir2_path = EYEOS_TESTS_TMP_PATH . '/mySysDir';
     $this->group = UMManager::getGroupByName(SERVICE_UM_DEFAULTUSERSGROUP);
     if (!self::$AliceCreated) {
         try {
             //create group "wonderland"
             $wonderland = UMManager::getInstance()->getNewGroupInstance();
             $wonderland->setName('wonderland');
             UMManager::getInstance()->createGroup($wonderland);
         } catch (EyeGroupAlreadyExistsException $e) {
         }
         try {
             //create user "alice"
             $alice = UMManager::getInstance()->getNewUserInstance();
             $alice->setName('alice');
             $alice->setPassword('alice', true);
             $alice->setPrimaryGroupId($wonderland->getId());
             UMManager::getInstance()->createUser($alice);
         } catch (EyeUserAlreadyExistsException $e) {
         }
         self::$AliceCreated = true;
     }
     AdvancedPathLib::rmdirs(USERS_PATH . '/john/' . USERS_FILES_DIR, true);
     AdvancedPathLib::rmdirs(USERS_PATH . '/john/' . USERS_METAFILES_DIR, true);
     if (!is_dir(EYEOS_TESTS_TMP_PATH)) {
         mkdir(EYEOS_TESTS_TMP_PATH, 0777, true);
     }
     AdvancedPathLib::rmdirs(EYEOS_TESTS_TMP_PATH, true);
     $this->fixture_file1 = FSI::getFile('home://~john/myHomeFile.ext');
     file_put_contents($this->fixture_file1_path, 'some content');
     $this->fixture_file2 = FSI::getFile('sys:///tests/tmp/mySysFile.ext');
     file_put_contents($this->fixture_file2_path, 'some other content');
     $this->fixture_dir1 = FSI::getFile('home://~john/myHomeDir');
     if (!is_dir($this->fixture_dir1_path)) {
         mkdir($this->fixture_dir1_path);
     }
     $this->fixture_dir2 = FSI::getFile('sys:///tests/tmp/mySysDir');
     if (!is_dir($this->fixture_dir2_path)) {
         mkdir($this->fixture_dir2_path);
     }
     $proc = new Process('example');
     $loginContext = new LoginContext('example', new Subject());
     $loginContext->getSubject()->getPrivateCredentials()->append(new EyeosPasswordCredential('john', 'john'));
     $loginContext->login();
     $proc->setLoginContext($loginContext);
     ProcManager::getInstance()->execute($proc);
     self::$MyProcPid = $proc->getPid();
 }
 public function tearDown()
 {
     try {
         UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('userLogin0'));
     } catch (EyeNoSuchPrincipalException $e) {
     }
     try {
         UMManager::getInstance()->deletePrincipal(UMManager::getGroupByName('group0'));
     } catch (EyeNoSuchPrincipalException $e) {
     }
 }
 public function tearDown()
 {
     if (self::$ClassTearDownToRun) {
         $this->loginAsRoot();
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('alice'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('bob'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('charlie'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getGroupByName('wonderland'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         $conf = SharingManager::getConfiguration('SharingManager');
         $providerClassName = (string) $conf->providerClassName[0];
         if ($providerClassName == 'DefaultSQLiteShareInfoProvider') {
             if (is_file(USERS_PATH . '/' . $this->owner->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->owner->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
             if (is_file(USERS_PATH . '/' . $this->collaborator1->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->collaborator1->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
             if (is_file(USERS_PATH . '/' . $this->collaborator2->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->collaborator2->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
             if (is_file(USERS_PATH . '/' . $this->collaborator3->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->collaborator3->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
         } else {
             if ($providerClassName == 'DefaultMySQLShareInfoProvider') {
                 require_once SERVICE_SHARING_SHARINGMANAGERS_PROVIDERS_PATH . '/DefaultMySQLShareInfoProvider.php';
                 $dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
                 $dao->send('TRUNCATE TABLE ' . DefaultMySQLShareInfoProvider::SHAREINFO_TABLE_NAME);
                 $dao->send('TRUNCATE TABLE ShareableVirtualFilesHandler');
             }
         }
         try {
             ProcManager::getInstance()->kill(ProcManager::getInstance()->getProcessByPid(self::$MyProcPid));
         } catch (EyeProcException $e) {
         }
         ProcManager::getInstance()->setCurrentProcess(self::$InitProcessToRestore);
     }
 }