Beispiel #1
0
 public function test_indexEmptyProject()
 {
     $project = USVN_Project::createProject(array('projects_name' => 'empty', 'projects_start_date' => '1984-12-03 00:00:00'), "john", true, true, true, false);
     $this->request->setParam('project', 'empty');
     $this->runAction('index');
     $this->assertContains("http://localhost/test/svn/empty", $this->getBody());
     $this->assertNotContains("http://localhost/test/svn/empty/trunk", $this->getBody());
 }
Beispiel #2
0
 public function setUp()
 {
     parent::setUp();
     $table = new USVN_Db_Table_Users();
     $this->_user = $table->fetchNew();
     $this->_user->setFromArray(array('users_login' => 'test', 'users_password' => 'password', 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**'));
     $this->_user->save();
     $this->_projectid1 = USVN_Project::createProject(array('projects_name' => "project1"), "test", true, false, false, true)->id;
     $this->_projectid2 = USVN_Project::createProject(array('projects_name' => "project2"), "test", true, false, false, true)->id;
     $group_table = new USVN_Db_Table_Groups();
     $group = $group_table->fetchNew();
     $group->setFromArray(array("groups_name" => "toto"));
     $this->_groupid1 = $group->save();
     $group_table = new USVN_Db_Table_Groups();
     $group = $group_table->fetchNew();
     $group->setFromArray(array("groups_name" => "titi"));
     $this->_groupid2 = $group->save();
 }
Beispiel #3
0
 /**
  * Import all SVN Repositories added
  *
  * @throws USVN_Exception
  * @return array USVN_Db_Table_Row_Project
  */
 public function importSVNRepositories()
 {
     if (count($this->_repos)) {
         foreach ($this->_repos as $k => $repo) {
             $project = USVN_Project::createProject(array('projects_name' => $repo['name'], 'projects_description' => $repo['options']['description']), $repo['options']['login'], $repo['options']['creategroup'], $repo['options']['addmetogroup'], $repo['options']['admin'], 0);
             //0, we don't want to create branch's, trunk's and tag's directory
             //no need to check if the project have been created, an exception will be throw in this case
             $this->_repos_imported[] = $project;
             unset($this->_repos[$k]);
         }
     }
     return $this->_repos_imported;
 }
Beispiel #4
0
 public function deleteAction()
 {
     USVN_Project::deleteProject(str_replace(USVN_URL_SEP, '/', $this->getRequest()->getParam('name')));
     $this->_redirect("/admin/project/");
 }
Beispiel #5
0
 /**
  * Create a project
  *
  * @param array Fields data
  * @param string The creating user
  * @param bool Create a group for the project
  * @param bool Add user into group
  * @param bool Add user as admin for the project
  * @param bool Create SVN standard directories
  * @return USVN_Db_Table_Row_Project
  */
 public static function createProject(array $data, $login, $create_group, $add_user_to_group, $create_admin, $create_svn_directories)
 {
     //We need check if admin exist before create project because we can't go back
     $user_table = new USVN_Db_Table_Users();
     $user = $user_table->fetchRow(array('users_login = ?' => $login));
     if ($user === null) {
         throw new USVN_Exception(T_('Login %s not found'), $login);
     }
     $groups = new USVN_Db_Table_Groups();
     if ($create_group) {
         $group = $groups->fetchRow(array('groups_name = ?' => $data['projects_name']));
         if ($group !== null) {
             throw new USVN_Exception(T_("Group %s already exists."), $data['projects_name']);
         }
     }
     try {
         $table = new USVN_Db_Table_Projects();
         $table->getAdapter()->beginTransaction();
         $project = $table->createRow($data);
         $project->save();
         USVN_Project::createProjectSVN($data['projects_name'], $create_svn_directories);
         if ($create_group) {
             $group = $groups->createRow();
             $group->description = sprintf(T_("Autocreated group for project %s"), $data['projects_name']);
             $group->name = $data['projects_name'];
             $group->save();
             $project->addGroup($group);
             USVN_Project::ApplyFileRights($project, $group, $create_svn_directories);
         }
         if ($create_group && $add_user_to_group) {
             $group->addUser($user);
             $group->promoteUser($user);
         }
         if ($create_admin) {
             $project->addUser($user);
         }
     } catch (Exception $e) {
         $table->getAdapter()->rollBack();
         throw $e;
     }
     $table->getAdapter()->commit();
     return $project;
 }
Beispiel #6
0
 public function testDeleteProject()
 {
     USVN_Project::createProject(array('projects_name' => 'InsertProjectOK', 'projects_start_date' => '1984-12-03 00:00:00'), "test", true, true, true, false);
     USVN_Project::deleteProject('InsertProjectOK');
     $table = new USVN_Db_Table_Projects();
     $this->assertFalse($table->isAProject('InsertProjectOk'), "Le projet n'est pas supprime");
     $table_groups = new USVN_Db_Table_Groups();
     $this->assertFalse($table_groups->isAGroup('InsertProjectOk'), "Le groupe n'est pas supprime");
 }
Beispiel #7
0
 /**
  * Genere un tableau de projet
  *
  * @param int $n
  */
 function _generateProjects($n)
 {
     $table = new USVN_Db_Table_Projects();
     $ret = array();
     for ($i = 1; $i <= $n; $i++) {
         $ret[$i - 1] = USVN_Project::createProject(array('projects_name' => "project{$i}"), "test", true, false, false, false);
     }
     return $ret;
 }