public function setUp() { parent::setUp(); $this->project_name = 'firefox'; $this->namespace = 'jean-claude'; $this->repository_name = 'dusse'; $this->project = stub('Project')->getUnixName()->returns($this->project_name); $this->repository = aGitRepository()->withProject($this->project)->withNamespace($this->namespace)->withName($this->repository_name)->build(); $this->gerrit_server = mock('Git_RemoteServer_GerritServer'); $this->ssh = mock('Git_Driver_Gerrit_RemoteSSHCommand'); $this->logger = mock('BackendLogger'); $this->driver = new Git_Driver_GerritLegacy($this->ssh, $this->logger); }
public function setUp() { parent::setUp(); $fixture_dir = dirname(__FILE__) . '/_fixtures'; $this->manifest_directory = $fixture_dir . '/manifests'; $this->repository = aGitRepository()->withPath('linux/kernel.git')->withDescription('Linux4ever')->build(); $this->another_repository = aGitRepository()->withPath('mozilla/firefox.git')->withDescription('free and open-source web browser')->build(); $this->singapour_mirror = new Git_Mirror_Mirror(mock('PFUser'), $this->singapour_mirror_id, 'singapour.io', 'singapour', 'PLP'); $this->noida_mirror = new Git_Mirror_Mirror(mock('PFUser'), $this->noida_mirror_id, 'noida.org', 'noida', 'test'); $this->generator = mock('Git_Mirror_ManifestFileGenerator'); $this->data_mapper = mock('Git_Mirror_MirrorDataMapper'); stub($this->data_mapper)->fetchAll()->returns(array($this->singapour_mirror, $this->noida_mirror)); $this->manager = new Git_Mirror_ManifestManager($this->data_mapper, $this->generator); }
public function setUp() { parent::setUp(); $this->project_manager = mock('ProjectManager'); $this->repository_factory = mock('GitRepositoryFactory'); $this->gpig_project = mock('Project'); stub($this->gpig_project)->getId()->returns($this->gpig_project_id); stub($this->gpig_project)->getUnixName()->returns($this->gpig_project_name); $this->goldfish_repository = aGitRepository()->withProject($this->gpig_project)->withName('device/generic/goldfish')->build(); stub($this->repository_factory)->getByProjectNameAndPath($this->gpig_project_name, 'device/generic/goldfish.git')->returns($this->goldfish_repository); stub($this->repository_factory)->getRepositoryById($this->repository_id)->returns($this->goldfish_repository); $this->apache_repository = aGitRepository()->withProject($this->gpig_project)->withName('apache-2.5')->build(); stub($this->repository_factory)->getByProjectNameAndPath($this->gpig_project_name, 'apache-2.5.git')->returns($this->apache_repository); stub($this->project_manager)->getProject($this->gpig_project_id)->returns($this->gpig_project); }
public function setUp() { parent::setUp(); $this->current_time = $_SERVER['REQUEST_TIME']; $this->time_in_the_past = 1414684049; $this->fixture_dir = dirname(__FILE__) . '/_fixtures'; $this->manifest_directory = $this->fixture_dir . '/manifests'; mkdir($this->manifest_directory); $this->kernel_repository = aGitRepository()->withPath('linux/kernel.git')->withDescription('Linux4ever')->build(); $this->firefox_repository = aGitRepository()->withPath('mozilla/firefox.git')->withDescription('free and open-source web browser')->build(); $this->singapour_mirror = new Git_Mirror_Mirror(mock('PFUser'), $this->singapour_mirror_id, 'singapour.com', 'singapour', 'SNP'); $this->manifest_file_for_singapour = $this->manifest_directory . "/manifest_mirror_{$this->singapour_mirror_id}.js.gz"; $this->logger = mock('Logger'); $this->generator = new Git_Mirror_ManifestFileGenerator($this->logger, $this->manifest_directory); }
public function setUp() { parent::setUp(); $this->gerrit_server = mock('Git_RemoteServer_GerritServer'); $this->logger = mock('BackendLogger'); stub($this->gerrit_server)->getHost()->returns($this->gerrit_server_host); stub($this->gerrit_server)->getHTTPPassword()->returns($this->gerrit_server_pass); stub($this->gerrit_server)->getLogin()->returns($this->gerrit_server_user); stub($this->gerrit_server)->getHTTPPort()->returns($this->gerrit_server_port); stub($this->gerrit_server)->getBaseUrl()->returns($this->gerrit_server_host . ':' . $this->gerrit_server_port); $this->project = stub('Project')->getUnixName()->returns($this->project_name); $this->repository = aGitRepository()->withProject($this->project)->withNamespace($this->namespace)->withName($this->repository_name)->build(); $this->guzzle_client = mock('Guzzle\\Http\\Client'); $this->guzzle_request = mock('Guzzle\\Http\\Message\\EntityEnclosingRequest'); $this->driver = new Git_Driver_GerritREST($this->guzzle_client, $this->logger); }
public function setUp() { parent::setUp(); $this->mirror_mapper = mock('Git_Mirror_MirrorDataMapper'); $this->serializer = new Git_Gitolite_ConfigPermissionsSerializer($this->mirror_mapper, 'whatever'); $this->project = stub('Project')->getUnixName()->returns('foo'); $this->repository = aGitRepository()->withId(115)->withProject($this->project)->build(); $user_mirror1 = aUser()->withUserName('git_mirror_1')->build(); $this->mirror_1 = new Git_Mirror_Mirror($user_mirror1, 1, 'url', 'hostname', 'EUR'); $user_mirror2 = aUser()->withUserName('git_mirror_2')->build(); $this->mirror_2 = new Git_Mirror_Mirror($user_mirror2, 2, 'url', 'hostname', 'IND'); $this->permissions_manager = mock('PermissionsManager'); PermissionsManager::setInstance($this->permissions_manager); }
private function aRepoWithPath($path) { return aGitRepository()->withPath($this->project_name . '/' . $path . '.git')->withProject($this->project)->build(); }
public function testRewindAccessRightsToGerritUserWhenRepoIsMigratedToGerrit() { $prj = new MockProject($this); $prj->setReturnValue('getUnixName', 'project1'); $prj->setReturnValue('getId', 404); // List all repo stub($this->repository_factory)->getAllRepositoriesOfProject($prj)->once()->returns(array(aGitRepository()->withProject($prj)->withId(4)->withName('before_migration_to_gerrit')->withNamespace('')->build(), aGitRepository()->withId(5)->withProject($prj)->withName('after_migration_to_gerrit')->withNamespace('')->withRemoteServerId(1)->build())); stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 4, 'PLUGIN_GIT_READ')->returns(array('2')); stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 4, 'PLUGIN_GIT_WRITE')->returns(array('3')); stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 4, 'PLUGIN_GIT_WPLUS')->returns(array('125')); stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 5, 'PLUGIN_GIT_READ')->returns(array('2')); stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 5, 'PLUGIN_GIT_WRITE')->returns(array('3')); stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 5, 'PLUGIN_GIT_WPLUS')->returns(array('125')); // Ensure file is correct $result = $this->project_serializer->dumpProjectRepoConf($prj); $expected = file_get_contents($this->_fixDir . '/perms/migrated_to_gerrit.conf'); $this->assertIdentical($expected, $result); }
public function itDelegatesForkToGitManager() { $repositories = array(aGitRepository()->build(), aGitRepository()->build()); $to_project = mock('Project'); $namespace = 'namespace'; $scope = GitRepository::REPO_SCOPE_INDIVIDUAL; $user = mock('User'); $response = mock('Layout'); $redirect_url = '/stuff'; $this->manager->expectOnce('forkRepositories', array($repositories, $to_project, $user, $namespace, $scope)); $this->actions->fork($repositories, $to_project, $namespace, $scope, $user, $response, $redirect_url); }
public function testGetAccessTypeShouldIncludesNameSpace() { $repository = aGitRepository()->withName('bionic')->withNamespace('u/johndoe/uber')->withProject($this->project)->build(); $urls = $this->backend->getAccessUrl($repository); $url = array_shift($urls); // url ends by the namespace + name $this->assertPattern('%/gpig/u/johndoe/uber/bionic\\.git$%', $url); }
public function itReturnsAGerritServer() { $repo = aGitRepository()->withRemoteServerId($this->server_id)->build(); $server = $this->factory->getServer($repo); $this->assertIsA($server, 'Git_RemoteServer_GerritServer'); }