Example #1
0
 /**
  * Returns the content of a directory in Subversion according to user permissions
  * 
  * <ul>
  *   <li>If user cannot see the content it gets an empty array.</li>
  *   <li>The returned content is relative (/project/tags) gives array("1.0", "2.0").</li>
  * </ul>
  * 
  * Error codes:
  * * 3001, Invalid session (wrong $sessionKey)
  * * 3002, User do not have access to the project
  *
  * @param String  $sessionKey Session key of the desired project admin
  * @param Integer $group_id    ID of the project the subversion repository belongs to
  * @param String  $path        Path to the directory to list (eg. '/tags')
  * 
  * @return ArrayOfString The list of directories
  */
 public function getSvnPath($sessionKey, $group_id, $path)
 {
     try {
         $current_user = $this->soap_request_validator->continueSession($sessionKey);
         $project = $this->soap_request_validator->getProjectById($group_id, 'getSVNPath');
         $this->soap_request_validator->assertUserCanAccessProject($current_user, $project);
         return $this->svn_repository_listing->getSvnPath($current_user, $project, $path);
     } catch (Exception $e) {
         return new SoapFault((string) $e->getCode(), $e->getMessage());
     }
 }
 /**
  * Returns the detailed content of a directory in Subversion according to user permissions
  *
  * <ul>
  *   <li>If user cannot see the content it gets an empty array.</li>
  *   <li>The returned content is relative (/project/tags) gives
  *      array(
  *          0 => array(
  *              'path' => '/tags',
  *              'author => 169,
  *              'timestamp' => 1545265465,
  *              'message' => 'some commit message'),
  *          1 => array(
  *              'path' => '/tags',
  *              'author => 587,
  *              'timestamp' => 11545824,
  *              'message' => 'some other commit message'),
  *      ).</li>
  * </ul>
  *
  * Error codes:
  * * 3001, Invalid session (wrong $sessionKey)
  * * 3002, User do not have access to the project
  *
  * @param String  $sessionKey Session key of the desired project admin
  * @param Integer $group_id    ID of the project the subversion repository belongs to
  * @param String  $path        Path to the directory to list (eg. '/tags')
  * @param String  $sort        The type of sort wanted: ASC or DESC
  *
  * @return ArrayOfSvnPathDetails The detailed list of directories
  */
 public function getSvnPathsWithLogDetails($sessionKey, $group_id, $path, $sort)
 {
     try {
         $data = array();
         $current_user = $this->soap_request_validator->continueSession($sessionKey);
         $project = $this->soap_request_validator->getProjectById($group_id, 'getSVNPath');
         $this->soap_request_validator->assertUserCanAccessProject($current_user, $project);
         $path_logs = $this->svn_repository_listing->getSvnPathsWithLogDetails($current_user, $project, $path, $sort);
         foreach ($path_logs as $path_log) {
             $data[] = $path_log->exportToSoap();
         }
         return $data;
     } catch (Exception $e) {
         return new SoapFault((string) $e->getCode(), $e->getMessage());
     }
 }
 public function itReturnsAnEmptyArrayIfEmptyRepository()
 {
     $svnlook = mock('SVN_Svnlook');
     $svn_repo_listing = new SVN_RepositoryListing($this->svn_perms_mgr, $svnlook, $this->user_manager);
     $content = array('/');
     stub($svnlook)->getDirectoryListing($this->project, '/')->returns($content);
     $last_revision = $svn_repo_listing->getSvnPathsWithLogDetails($this->user, $this->project, '/', $this->order);
     $this->assertTrue(is_array($last_revision));
     $this->assertCount($last_revision, 0);
 }
 public function itExecuteTheCommandOnTheSystem()
 {
     $user = mock('User');
     $project = stub('Project')->getUnixName()->returns($this->project_name);
     $svn_path = '/tags';
     $svn_repo_listing = TestHelper::getPartialMock('SVN_RepositoryListing', array('getDirectoryListing'));
     $svn_perms_mgr = stub('SVN_PermissionsManager')->userCanRead()->returns(true);
     $svn_repo_listing = new SVN_RepositoryListing($svn_perms_mgr);
     $tags = $svn_repo_listing->getSvnPath($user, $project, $svn_path);
     $tags = array_values($tags);
     $tags = sort($tags);
     $this->assertEqual($tags, array('1.0', '2.0'));
 }