Exemplo n.º 1
0
 /**
  * @link https://github.com/Block8/PHPCI/issues/484
  * @covers PHPUnit::execute
  */
 public function testExecute_CreateGitlabProjectWithoutPort()
 {
     $reference = 'git@gitlab.block8.net:block8/phpci.git';
     $returnValue = $this->testedService->createProject('Gitlab', 'gitlab', $reference);
     $this->assertEquals('git', $returnValue->getAccessInformation('user'));
     $this->assertEquals('gitlab.block8.net', $returnValue->getAccessInformation('domain'));
     $this->assertEquals('block8/phpci', $returnValue->getReference());
 }
Exemplo n.º 2
0
 /**
  * Add a new project. Handles both the form, and processing.
  */
 public function add()
 {
     $this->layout->title = Lang::get('add_project');
     $this->requireAdmin();
     $method = $this->request->getMethod();
     $pub = null;
     $values = $this->getParams();
     if ($method != 'POST') {
         $sshKey = new SshKey();
         $key = $sshKey->generate();
         $values['key'] = $key['private_key'];
         $values['pubkey'] = $key['public_key'];
         $pub = $key['public_key'];
     }
     $form = $this->projectForm($values);
     if ($method != 'POST' || $method == 'POST' && !$form->validate()) {
         $view = new b8\View('ProjectForm');
         $view->type = 'add';
         $view->project = null;
         $view->form = $form;
         $view->key = $pub;
         return $view->render();
     } else {
         $title = $this->getParam('title', 'New Project');
         $reference = $this->getParam('reference', null);
         $type = $this->getParam('type', null);
         $options = array('ssh_private_key' => $this->getParam('key', null), 'ssh_public_key' => $this->getParam('pubkey', null), 'build_config' => $this->getParam('build_config', null), 'allow_public_status' => $this->getParam('allow_public_status', 0), 'branch' => $this->getParam('branch', null), 'group' => $this->getParam('group_id', null));
         $project = $this->projectService->createProject($title, $type, $reference, $options);
         $response = new b8\Http\Response\RedirectResponse();
         $response->setHeader('Location', PHPCI_URL . 'project/view/' . $project->getId());
         return $response;
     }
 }