public function testRenameTo()
 {
     /**** existing home file ****/
     $this->assertFalse(is_file($this->fixture_metafile1_path));
     $meta = new VirtualFileMetaData();
     $meta->set('myDummyMetaValue', 'someValueHere');
     $this->fixture_file1->setMeta($meta);
     $this->assertTrue(is_file($this->fixture_metafile1_path));
     $this->assertTrue(is_file($this->fixture_file1_path));
     $targetPath = USERS_PATH . '/john/' . USERS_FILES_DIR . '/myHomeFile_renamed.ext';
     $this->assertFalse(is_file($targetPath));
     $this->assertEquals('someValueHere', $this->fixture_file1->getMeta()->get('myDummyMetaValue'));
     $originalContent = file_get_contents($this->fixture_file1_path);
     $this->assertTrue($this->fixture_file1->renameTo('myHomeFile_renamed.ext'));
     $this->assertFalse(is_file($this->fixture_file1_path));
     $this->assertTrue(is_file($targetPath));
     $targetFile = FSI::getFile('home://~john/myHomeFile_renamed.ext');
     $this->assertFalse(is_file($this->fixture_metafile1_path));
     $this->assertTrue(is_file(USERS_PATH . '/john/' . USERS_METAFILES_DIR . '/' . USERS_FILES_DIR . '/myHomeFile_renamed.ext.xml'));
     $this->assertEquals('someValueHere', $targetFile->getMeta()->get('myDummyMetaValue'));
     $this->assertEquals($originalContent, file_get_contents($targetPath));
     $this->tearDown();
     $this->setUp();
     /**** non-existing home file ****/
     unlink($this->fixture_file1_path);
     $this->assertFalse(is_file($this->fixture_file1_path));
     try {
         $this->fixture_file1->renameTo('test');
         $this->fail();
     } catch (EyeFileNotFoundException $e) {
         // normal situation
     }
     /**** home dir ****/
     $meta = new VirtualFileMetaData();
     $meta->set('myDummyMetaValue', 'someValueHere');
     $this->fixture_dir1->setMeta($meta);
     $this->assertTrue(is_dir($this->fixture_dir1_path));
     $targetPath = USERS_PATH . '/john/' . USERS_FILES_DIR . '/myHomeDir_renamed';
     $this->assertFalse(is_dir($targetPath));
     $this->assertEquals('someValueHere', $this->fixture_dir1->getMeta()->get('myDummyMetaValue'));
     $oldDir = clone $this->fixture_dir1;
     $this->assertTrue($this->fixture_dir1->renameTo('myHomeDir_renamed'));
     $this->assertFalse(is_dir($this->fixture_dir1_path));
     $this->assertTrue(is_dir($targetPath));
     $targetFile = FSI::getFile('home://~john/myHomeDir_renamed');
     $this->assertNull($oldDir->getMeta());
     $this->assertEquals('someValueHere', $targetFile->getMeta()->get('myDummyMetaValue'));
     /**** sys file ****/
     $this->assertTrue(is_file($this->fixture_file2_path));
     $targetPath = EYEOS_TESTS_TMP_PATH . '/mySysFile_renamed.ext';
     $this->assertFalse(is_file($targetPath));
     $originalContent = file_get_contents($this->fixture_file2_path);
     //as normal user => fails
     try {
         $this->fixture_file2->renameTo('mySysFile_renamed.ext');
         $this->fail();
     } catch (EyeAccessControlException $e) {
     }
     //as root => succeeds
     self::logInAsRoot();
     $this->assertTrue($this->fixture_file2->renameTo('mySysFile_renamed.ext'));
     self::logInAsJohn();
     $this->assertFalse(is_file($this->fixture_file2_path));
     $this->assertTrue(is_file($targetPath));
     $targetFile = FSI::getFile('sys:///tests/tmp/mySysFile_renamed.ext');
     $this->assertEquals($originalContent, file_get_contents($targetPath));
     /**** sys dir ****/
     $this->assertTrue(is_dir($this->fixture_dir2_path));
     $targetPath = EYEOS_TESTS_TMP_PATH . '/mySysDir_renamed';
     $this->assertFalse(is_dir($targetPath));
     //as normal user => fails
     try {
         $this->fixture_dir2->renameTo('mySysDir_renamed');
         $this->fail();
     } catch (EyeAccessControlException $e) {
     }
     //as root => succeeds
     self::logInAsRoot();
     $this->assertTrue($this->fixture_dir2->renameTo('mySysDir_renamed'));
     self::logInAsJohn();
     $this->assertFalse(is_dir($this->fixture_dir2_path));
     $this->assertTrue(is_dir($targetPath));
     $targetFile = FSI::getFile('home://~john/mySysDir_renamed');
 }
 public function getMeta()
 {
     if ($this->realFile === null) {
         $loginContext = ProcManager::getInstance()->getCurrentProcess()->getLoginContext();
         $meta = new VirtualFileMetaData();
         $meta->setAll(array(self::METADATA_KEY_OWNER => $loginContext->getEyeosUser()->getName(), self::METADATA_KEY_GROUP => SERVICE_UM_DEFAULTUSERSGROUP, self::METADATA_KEY_PERMISSIONS => '-rwx------'));
         return $meta;
     }
     return parent::getMeta();
 }