コード例 #1
0
 /**
  * @covers PHPUnit::execute
  */
 public function testExecute_EmptyPublicStatus()
 {
     $project = new Project();
     $project->setAllowPublicStatus(1);
     $options = array('ssh_private_key' => 'private', 'ssh_public_key' => 'public', 'build_config' => 'config');
     $returnValue = $this->testedService->updateProject($project, 'Test Project', 'github', 'block8/phpci', $options);
     $this->assertEquals(0, $returnValue->getAllowPublicStatus());
 }
コード例 #2
0
ファイル: ProjectController.php プロジェクト: ntoniazzi/PHPCI
 /**
  * Edit a project. Handles both the form and processing.
  */
 public function edit($projectId)
 {
     $this->requireAdmin();
     $method = $this->request->getMethod();
     $project = $this->projectStore->getById($projectId);
     if (empty($project)) {
         throw new NotFoundException(Lang::get('project_x_not_found', $projectId));
     }
     $this->layout->title = $project->getTitle();
     $this->layout->subtitle = Lang::get('edit_project');
     $values = $project->getDataArray();
     $values['key'] = $values['ssh_private_key'];
     $values['pubkey'] = $values['ssh_public_key'];
     if ($values['type'] == "gitlab") {
         $accessInfo = $project->getAccessInformation();
         $reference = $accessInfo["user"] . '@' . $accessInfo["domain"] . ':' . $accessInfo["port"] . '/' . ltrim($project->getReference(), '/') . ".git";
         $values['reference'] = $reference;
     }
     if ($method == 'POST') {
         $values = $this->getParams();
     }
     $form = $this->projectForm($values, 'edit/' . $projectId);
     if ($method != 'POST' || $method == 'POST' && !$form->validate()) {
         $view = new b8\View('ProjectForm');
         $view->type = 'edit';
         $view->project = $project;
         $view->form = $form;
         $view->key = $values['pubkey'];
         return $view->render();
     }
     $title = $this->getParam('title', Lang::get('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), 'archived' => $this->getParam('archived', 0), 'branch' => $this->getParam('branch', null), 'group' => $this->getParam('group_id', null));
     $project = $this->projectService->updateProject($project, $title, $type, $reference, $options);
     $response = new b8\Http\Response\RedirectResponse();
     $response->setHeader('Location', PHPCI_URL . 'project/view/' . $project->getId());
     return $response;
 }