/** * @covers PHPUnit::execute */ public function testExecute_CreateBuildWithExtra() { $project = new Project(); $project->setType('bitbucket'); $project->setId(101); $returnValue = $this->testedService->createBuild($project, null, null, null, null, array('item1' => 1001)); $this->assertEquals(1001, $returnValue->getExtra('item1')); }
public function setUp() { $project = new Project(); $project->setId(3); $project->setBranch(self::BRANCH); $project->setTitle('Test'); $this->project = $project; $this->timezone = date_default_timezone_get(); date_default_timezone_set('UTC'); }
/** * @covers PHPUnit::execute */ public function testExecute_TestProjectAccessInformation() { $info = array('item1' => 'Item One', 'item2' => 2); $project = new Project(); $project->setAccessInformation($info); $this->assertEquals('Item One', $project->getAccessInformation('item1')); $this->assertEquals(2, $project->getAccessInformation('item2')); $this->assertNull($project->getAccessInformation('item3')); $this->assertEquals($info, $project->getAccessInformation()); }
/** * Wrapper for creating a new build. * * @param Project $project * @param string $commitId * @param string $branch * @param string $committer * @param string $commitMessage * @param array $extra * * @return array * * @throws Exception */ protected function createBuild(Project $project, $commitId, $branch, $committer, $commitMessage, array $extra = null) { // Check if a build already exists for this commit ID: $builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId); if ($builds['count']) { return array('status' => 'ignored', 'message' => sprintf('Duplicate of build #%d', $builds['items'][0]->getId())); } // If not, create a new build job for it: $build = $this->buildService->createBuild($project, $commitId, $branch, $committer, $commitMessage, $extra); $build = BuildFactory::getBuild($build); // Send a status postback if the build type provides one: $build->sendStatusPostback(); return array('status' => 'ok', 'buildID' => $build->getID()); }
/** * Set Project - Accepts a Project model. * * @param $value \PHPCI\Model\Project */ public function setProjectObject(\PHPCI\Model\Project $value) { return $this->setProjectId($value->getId()); }
/** * Formats a list of builds into rows suitable for the dropdowns in the PHPCI header bar. * @param $builds * @return array */ protected function formatBuilds($builds) { Project::$sleepable = array('id', 'title', 'reference', 'type'); $rtn = array('count' => $builds['count'], 'items' => array()); foreach ($builds['items'] as $build) { $item = $build->toArray(1); $header = new b8\View('Build/header-row'); $header->build = $build; $item['header_row'] = $header->render(); $rtn['items'][$item['id']] = $item; } ksort($rtn['items']); return $rtn; }
/** * @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()); }
/** * In circumstances where it is necessary, populate access information based on other project properties. * @see ProjectService::createProject() * @param Project $project */ protected function processAccessInformation(Project &$project) { $matches = array(); $reference = $project->getReference(); if ($project->getType() == 'gitlab') { $info = array(); if (preg_match('`^(.+)@(.+):([0-9]*)\\/?(.+)\\.git`', $reference, $matches)) { $info['user'] = $matches[1]; $info['domain'] = $matches[2]; $info['port'] = $matches[3]; $project->setReference($matches[4]); } $project->setAccessInformation($info); } }
protected function addProject(Form $form) { $values = $form->getValues(); $matches = array(); if ($values['type'] == "gitlab" && preg_match('`^(.*)@(.*):(.*)/(.*)\\.git`', $values['reference'], $matches)) { $info = array(); $info['user'] = $matches[1]; $info['domain'] = $matches[2]; $values['access_information'] = serialize($info); $values['reference'] = $matches[3] . "/" . $matches[4]; } $values['ssh_private_key'] = $values['key']; $values['ssh_public_key'] = $values['pubkey']; $project = new Project(); $project->setValues($values); $project = $this->projectStore->save($project); header('Location: ' . PHPCI_URL . 'project/view/' . $project->getId()); die; }