Esempio n. 1
0
 public function test_listDirectory()
 {
     @mkdir('tests/tmp/dir');
     @mkdir('tests/tmp/dir/1');
     @mkdir('tests/tmp/dir/2');
     @mkdir('tests/tmp/dir/3');
     $list = USVN_DirectoryUtils::listDirectory('tests/tmp/dir/');
     $this->assertTrue(in_array('1', $list));
     $this->assertTrue(in_array('2', $list));
     $this->assertTrue(in_array('3', $list));
     $this->assertFalse(in_array('..', $list));
     $this->assertFalse(in_array('.svn', $list));
     USVN_DirectoryUtils::removeDirectory('tests/tmp/dir');
 }
Esempio n. 2
0
File: Test.php Progetto: phpscr/usvn
    protected function setUp()
    {
        error_reporting(E_ALL | E_STRICT);
        date_default_timezone_set('UTC');
        $this->_path = getcwd();
        $this->setConsoleLocale();
        USVN_Translation::initTranslation('en_US', 'app/locale');
        USVN_DirectoryUtils::removeDirectory('tests/');
        mkdir("tests");
        mkdir("tests/tmp");
        mkdir("tests/tmp/svn");
        file_put_contents('tests/test.ini', '[general]
subversion.path = "' . getcwd() . '/tests/tmp/"
subversion.passwd = "' . getcwd() . '/tests/tmp/htpasswd"
subversion.authz = "' . getcwd() . '/tests/tmp/authz"
subversion.url = "http://localhost/"
version = "0.8.4"
translation.locale = "en_US"
');
        $config = new USVN_Config_Ini('tests/test.ini', 'general');
        Zend_Registry::set('config', $config);
    }
Esempio n. 3
0
 /**
  * Remove a directory even if it is not empty.
  */
 public static function removeDirectory($remove_path)
 {
     if (!file_exists($remove_path)) {
         return;
     }
     if (($path = realpath($remove_path)) !== FALSE) {
         if (@chmod($path, 0777) === FALSE) {
             throw new USVN_Exception(T_("Can't delete directory %s. Permission denied."), $path);
         }
         try {
             if (is_dir($path)) {
                 $dh = opendir($path);
             } else {
                 return;
             }
         } catch (Exception $e) {
             return;
         }
         while (($file = readdir($dh)) !== false) {
             if ($file != '.' && $file != '..') {
                 if (is_dir($path . DIRECTORY_SEPARATOR . $file)) {
                     USVN_DirectoryUtils::removeDirectory($path . DIRECTORY_SEPARATOR . $file);
                 } else {
                     if (chmod($path . DIRECTORY_SEPARATOR . $file, 0777) === FALSE) {
                         throw new USVN_Exception(T_("Can't delete file %s.", $path . DIRECTORY_SEPARATOR . $file));
                     }
                     unlink($path . DIRECTORY_SEPARATOR . $file);
                 }
             }
         }
         closedir($dh);
         if (@rmdir($path) === FALSE) {
             throw new USVN_Exception(T_("Can't delete directory %s."), $path);
         }
     }
 }
Esempio n. 4
0
 protected function tearDown()
 {
     USVN_DirectoryUtils::removeDirectory($this->_menudir);
     parent::tearDown();
 }
Esempio n. 5
0
 /**
  * Create standard svn directories
  * /trunk
  * /tags
  * /branches
  *
  * @param string Path to create subversion
  */
 public static function createStandardDirectories($path)
 {
     $tmpdir = USVN_DirectoryUtils::getTmpDirectory();
     try {
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "trunk");
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "branches");
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "tags");
         USVN_SVNUtils::_svnImport($path, $tmpdir);
     } catch (Exception $e) {
         USVN_DirectoryUtils::removeDirectory($path);
         USVN_DirectoryUtils::removeDirectory($tmpdir);
         throw $e;
     }
     USVN_DirectoryUtils::removeDirectory($tmpdir);
 }
Esempio n. 6
0
 public function testImportSVNRepositoriesOk()
 {
     try {
         $table = new USVN_Db_Table_Users();
         $obj = $table->fetchNew();
         $obj->setFromArray(array('users_login' => 'user_test', 'users_password' => 'password', 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**'));
         $obj->save();
     } catch (USVN_Exception $e) {
         print $e->getMessage() . "\n";
         $this->fail();
     }
     $path = 'tests/tmp/svn/test/';
     mkdir($path);
     USVN_SVNUtils::createSvn($path . 'test');
     USVN_SVNUtils::createSvn($path . 'test2');
     mkdir($path . 'test3');
     USVN_SVNUtils::createSvn($path . 'test3/test3');
     $options = array('recursive' => true, 'login' => 'user_test');
     $imp = new USVN_ImportSVNRepositories();
     $results = $imp->lookAfterSVNRepositoriesToImport($path, $options);
     if (count($results) != 3) {
         $this->fail();
     }
     $imp->addSVNRepositoriesToImport($results, $options);
     try {
         $imp->importSVNRepositories();
     } catch (USVN_Exception $e) {
         print $e->getMessage() . "\n";
         $this->fail();
     }
     USVN_DirectoryUtils::removeDirectory($path);
 }
Esempio n. 7
0
 public static function deleteProject($project_name)
 {
     $table = new USVN_Db_Table_Projects();
     $project = $table->fetchRow(array('projects_name = ?' => $project_name));
     if ($project === null) {
         throw new USVN_Exception(T_("Project %s doesn't exist."), $project_name);
     }
     $project->delete();
     $groups = new USVN_Db_Table_Groups();
     $where = $groups->getAdapter()->quoteInto("groups_name = ?", $project_name);
     $group = $groups->fetchRow($where);
     if ($group !== null) {
         $group->delete();
     }
     USVN_DirectoryUtils::removeDirectory(Zend_Registry::get('config')->subversion->path . DIRECTORY_SEPARATOR . 'svn' . DIRECTORY_SEPARATOR . $project_name);
 }